-
Notifications
You must be signed in to change notification settings - Fork 4
feat: implement preview packages with GitHub Actions and version conflict handling #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: pawcoding <78467484+pawcoding@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm.. sounds complicated. Maybe do it with bash, git and npm instead of semantic-release. Just always update by a patch version. Also this needs to be added to a GitHub action after the tests are passes. But only on branches other than the next and master branches.
Please also remove the test again.
Regarding the CONTRIBUTING.md
, not sure what is needed here regarding documenting the process. This can only be done by users with write access the repository anyways (currently only me). So it doesn't matter if outside contributors do a commit like this.
@copilot See the review above |
…emantic-release - Reverted release.config.cjs to original state - Removed test/release/preview-packages.spec.ts - Reverted CONTRIBUTING.md to original state - Added .github/workflows/preview-packages.yaml with bash/git/npm approach - Workflow runs after tests pass on branches other than master/next - Always increments patch version for preview packages - Publishes to npm with custom tag from [img:tag-name] pattern Co-authored-by: pawcoding <78467484+pawcoding@users.noreply.github.com>
I've completely refactored the approach as requested. Removed the semantic-release complexity and implemented a simple GitHub Actions workflow using bash, git, and npm instead. The workflow runs after tests pass on branches other than master/next, always increments patch version, and removed the test. The workflow is in commit 76d4d6f.
Implemented the requested changes in commit 76d4d6f. The new approach uses a GitHub Actions workflow that runs after tests pass on feature branches, detects the [img:tag-name] pattern, and publishes preview packages to npm with simple bash/git/npm commands. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks way better now, @copilot
Co-authored-by: pawcoding <78467484+pawcoding@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it looks good. I'll test it once I have to deploy a new preview version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a GitHub Actions workflow for creating preview packages that automatically publishes npm packages with custom tags when commit messages contain a special pattern [img:<tag-name>]
. The workflow handles version conflict resolution by querying npm for existing versions and incrementing counters to ensure unique version numbers.
- Adds automated preview package publishing triggered by commit message patterns
- Implements version conflict resolution with automatic counter incrementing
- Includes PR commenting functionality to notify about published preview packages
HIGHEST_COUNTER="$counter" | ||
fi | ||
fi | ||
done <<< "$(echo "$EXISTING_VERSIONS" | jq -r '.[]?' 2>/dev/null || echo "$EXISTING_VERSIONS" | grep -o '"[^"]*"' || echo)" |
Copilot
AI
Aug 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The complex fallback chain with jq and grep may not handle all npm response formats correctly. When jq fails, the grep pattern '"[^"]*"'
will extract quoted strings but may include non-version data. This could lead to incorrect version parsing or script failures. Consider using a more explicit approach to handle both array and string responses from npm.
done <<< "$(echo "$EXISTING_VERSIONS" | jq -r '.[]?' 2>/dev/null || echo "$EXISTING_VERSIONS" | grep -o '"[^"]*"' || echo)" | |
done <<< "$( | |
# Use jq to handle both array and string responses | |
if echo "$EXISTING_VERSIONS" | jq -e 'type == "array"' >/dev/null 2>&1; then | |
echo "$EXISTING_VERSIONS" | jq -r '.[]' | |
elif echo "$EXISTING_VERSIONS" | jq -e 'type == "string"' >/dev/null 2>&1; then | |
echo "$EXISTING_VERSIONS" | jq -r '.' | |
fi | |
)" |
Copilot uses AI. Check for mistakes.
npm publish --tag "$TAG_NAME" --access public | ||
|
||
echo "✅ Preview package published successfully!" | ||
echo "📦 Install with: npm install astro-loader-pocketbase@$TAG_NAME" |
Copilot
AI
Aug 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The package name 'astro-loader-pocketbase' is hardcoded in the installation command, but the actual package name is already retrieved from package.json on line 92. Use the $PACKAGE_NAME
variable instead to maintain consistency and avoid potential mismatches if the package name changes.
echo "📦 Install with: npm install astro-loader-pocketbase@$TAG_NAME" | |
echo "📦 Install with: npm install $PACKAGE_NAME@$TAG_NAME" |
Copilot uses AI. Check for mistakes.
Not sure but okay. Please @copilot handle the two open review suggestions |
Co-authored-by: pawcoding <78467484+pawcoding@users.noreply.github.com>
I've handled the two open review suggestions:
These improvements ensure the workflow will properly comment on PRs when preview packages are published. Commit 61a4676 |
This PR implements a new preview package feature using GitHub Actions that allows creating npm releases without going through the full release process. When a commit contains the pattern
[img:<tag-name>]
, a workflow automatically publishes a preview package to npm with automatic version conflict resolution.How it works
The GitHub Actions workflow:
master
andnext
[img:<tag-name>]
in commit messagesUsage
Create a preview package by adding the pattern to any commit message:
git commit --allow-empty -m "test: preview new feature [img:my-feature-preview]"
After tests pass, this will automatically publish the package to npm as
astro-loader-pocketbase@my-feature-preview
, which can be installed with:Version Conflict Resolution
The system automatically handles version conflicts by querying npm for existing versions and adding an incrementing counter:
1.0.1-my-feature.1
1.0.1-my-feature.2
1.0.1-my-feature.3
This ensures each publication gets a unique version number even when reusing the same tag name.
Use Cases
Technical Implementation
.github/workflows/preview-packages.yaml
that runs after the test workflowmaster
andnext
)The implementation maintains full backward compatibility - normal releases continue to work exactly as before, while preview releases operate independently without affecting the repository state.
Fixes #56.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.