generated from threeal/action-starter
-
Notifications
You must be signed in to change notification settings - Fork 2
chore: add automated release workflow with semantic versioning #51
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| changelog: | ||
| exclude: | ||
| labels: | ||
| - ignore-for-release | ||
| - dependencies | ||
| authors: | ||
| - dependabot | ||
| categories: | ||
| - title: Breaking Changes 🛠 | ||
| labels: | ||
| - breaking-change | ||
| - breaking | ||
| - title: New Features 🎉 | ||
| labels: | ||
| - feature | ||
| - enhancement | ||
| - feat | ||
| - title: Bug Fixes 🐛 | ||
| labels: | ||
| - bug | ||
| - fix | ||
| - title: Performance Improvements ⚡ | ||
| labels: | ||
| - performance | ||
| - perf | ||
| - title: Documentation 📚 | ||
| labels: | ||
| - documentation | ||
| - docs | ||
| - title: Other Changes | ||
| labels: | ||
| - "*" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: "Version to release (e.g., v1.1.0)" | ||
| required: true | ||
| type: string | ||
| update-major: | ||
| description: "Update major version tag (e.g., v1)" | ||
| required: true | ||
| type: boolean | ||
| default: true | ||
|
|
||
| jobs: | ||
| release: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| fetch-depth: 0 | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Validate version format | ||
| run: | | ||
| VERSION="${{ github.event.inputs.version }}" | ||
| if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then | ||
| echo "Error: Version must be in format vX.Y.Z or vX.Y.Z-prerelease" | ||
| echo "Examples: v1.1.0, v1.2.0-beta.1" | ||
| exit 1 | ||
| fi | ||
| echo "Version format is valid: $VERSION" | ||
|
|
||
| - name: Check if version already exists | ||
| run: | | ||
| VERSION="${{ github.event.inputs.version }}" | ||
| if git rev-parse "$VERSION" >/dev/null 2>&1; then | ||
| echo "Error: Tag $VERSION already exists" | ||
| exit 1 | ||
| fi | ||
| echo "Version $VERSION is available" | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: "20" | ||
|
|
||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 8 | ||
|
|
||
| - name: Setup buf | ||
| uses: bufbuild/buf-setup-action@v1 | ||
| with: | ||
| github_token: ${{ github.token }} | ||
|
|
||
| - name: Configure npm for buf registry | ||
| env: | ||
| BUF_TOKEN: ${{ secrets.BUF_TOKEN }} | ||
| run: | | ||
| npm config set @buf:registry https://buf.build/gen/npm/v1/ | ||
| npm config set //buf.build/gen/npm/v1/:_authToken "$BUF_TOKEN" | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install | ||
|
|
||
| - name: Run tests | ||
| run: pnpm test | ||
|
|
||
| - name: Build | ||
| run: pnpm run build | ||
|
|
||
| - name: Create semver tag | ||
| run: | | ||
| VERSION="${{ github.event.inputs.version }}" | ||
| git tag -a "$VERSION" -m "Release $VERSION" | ||
| git push origin "$VERSION" | ||
| echo "Created and pushed tag: $VERSION" | ||
|
|
||
| - name: Update major version tag | ||
| if: github.event.inputs.update-major | ||
| run: | | ||
| VERSION="${{ github.event.inputs.version }}" | ||
|
|
||
| # Extract major version (e.g., v1 from v1.2.3) | ||
| MAJOR_VERSION=$(echo "$VERSION" | grep -oE '^v[0-9]+') | ||
|
|
||
| echo "Updating major version tag: $MAJOR_VERSION" | ||
|
|
||
| # Delete remote tag if it exists | ||
| git push origin ":refs/tags/$MAJOR_VERSION" 2>/dev/null || true | ||
|
|
||
| # Create and push the major version tag | ||
| git tag -fa "$MAJOR_VERSION" -m "Update $MAJOR_VERSION to $VERSION" | ||
| git push --force origin "$MAJOR_VERSION" | ||
|
|
||
| echo "Updated and pushed tag: $MAJOR_VERSION -> $VERSION" | ||
|
|
||
| - name: Create GitHub Release | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | | ||
| VERSION="${{ github.event.inputs.version }}" | ||
|
|
||
| # Get the previous semver tag (v*.*.*, not v1/v2 major tags) | ||
| # This ensures predictable comparisons by excluding major version tags | ||
| PREVIOUS_TAG=$(git tag -l 'v*.*.*' --sort=-version:refname | grep -v "^$VERSION$" | head -n 1 || echo "") | ||
|
|
||
| if [ -z "$PREVIOUS_TAG" ]; then | ||
| echo "No previous tag found, generating notes from all commits" | ||
| gh release create "$VERSION" \ | ||
| --title "$VERSION" \ | ||
| --generate-notes | ||
| else | ||
| echo "Generating release notes from $PREVIOUS_TAG to $VERSION" | ||
| gh release create "$VERSION" \ | ||
| --title "$VERSION" \ | ||
| --generate-notes \ | ||
| --notes-start-tag "$PREVIOUS_TAG" | ||
| fi | ||
|
|
||
| echo "Created GitHub release: $VERSION" | ||
|
|
||
| - name: Summary | ||
| run: | | ||
| VERSION="${{ github.event.inputs.version }}" | ||
| MAJOR_VERSION=$(echo "$VERSION" | grep -oE '^v[0-9]+') | ||
|
|
||
| { | ||
| echo "## Release Summary" | ||
| echo "" | ||
| echo "✅ Successfully released **$VERSION**" | ||
| echo "" | ||
| echo "### Tags Created" | ||
| echo "- \`$VERSION\` (semver tag)" | ||
|
|
||
| if [[ "${{ github.event.inputs.update-major }}" == "true" ]]; then | ||
| echo "- \`$MAJOR_VERSION\` (major version tag, updated)" | ||
| fi | ||
|
|
||
| echo "" | ||
| echo "### Usage" | ||
| echo "" | ||
| echo "Users can now reference this action using:" | ||
| echo '```yaml' | ||
| echo "- uses: useblacksmith/setup-docker-builder@$MAJOR_VERSION" | ||
| echo "- uses: useblacksmith/setup-docker-builder@$VERSION" | ||
| echo '```' | ||
| echo "" | ||
| echo "🔗 [View Release](https://github.com/${{ github.repository }}/releases/tag/$VERSION)" | ||
| } >> "$GITHUB_STEP_SUMMARY" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.