-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Improve the Release Process Allowing to have Release Candidates (#3)
* chore: Update semantic release configuration for improved clarity Also add rc/* branch to allow to have prereleases before actually releasing. Add cargo verify-project to ensure the project is in a good state. Signed-off-by: Eden Reich <[email protected]> * chore: Nitpicking - Update CI workflow syntax for improved readability Signed-off-by: Eden Reich <[email protected]> * ci: Enhance GitHub Actions release workflow with improved configuration and error handling Signed-off-by: Eden Reich <[email protected]> --------- Signed-off-by: Eden Reich <[email protected]>
- Loading branch information
Showing
3 changed files
with
102 additions
and
77 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
--- | ||
name: Release | ||
|
||
on: | ||
|
@@ -13,15 +14,26 @@ jobs: | |
runs-on: ubuntu-24.04 | ||
permissions: | ||
contents: write | ||
issues: write | ||
pull-requests: write | ||
outputs: | ||
new_release_version: ${{ steps.semantic.outputs.new_release_version }} | ||
new_release_published: ${{ steps.semantic.outputs.new_release_published }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.ref }} | ||
fetch-depth: 0 | ||
persist-credentials: false | ||
ref: main | ||
|
||
- name: Configure Git signing | ||
run: | | ||
echo "${{ secrets.BOT_GPG_PRIVATE_KEY }}" | gpg --import | ||
git config --global user.signingkey ${{ secrets.BOT_GPG_KEY_ID }} | ||
git config --global commit.gpgsign true | ||
git config --global commit.signoff true | ||
git config --global user.name 'GitHub Actions Bot' | ||
git config --global user.email '[email protected]' | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
|
@@ -40,36 +52,48 @@ jobs: | |
- name: Create a release if needed | ||
id: semantic | ||
env: | ||
CI: true | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GIT_AUTHOR_NAME: "GitHub Actions Bot" | ||
GIT_AUTHOR_EMAIL: "[email protected]" | ||
GIT_COMMITTER_NAME: "GitHub Actions Bot" | ||
GIT_COMMITTER_EMAIL: "[email protected]" | ||
run: | | ||
dry_run_output=$(semantic-release --dry-run 2>&1 || true) | ||
# Create first release if not exists using gh cli - Initial Release Version 0.1.0 | ||
# This is an HACK because semantic release doesn't support versions under 1.0.0 | ||
# But if we already have a release then it respects it and start to increment from there | ||
if ! gh release view 0.1.0 >/dev/null 2>&1; then | ||
gh release create 0.1.0 --title "Initial Release" --notes "Initial Release" --target main | ||
fi | ||
# Run semantic-release in dry-run first to capture version | ||
DRY_OUTPUT=$(semantic-release --dry-run 2>&1 || true) | ||
# Check if there are no changes | ||
if $(echo "$dry_run_output" | grep -q "no new version is released"); then | ||
if $(echo "$DRY_OUTPUT" | grep -q "no new version is released"); then | ||
echo "No new release needed" | ||
echo "new_release_published=false" >> $GITHUB_OUTPUT | ||
exit 0 | ||
fi | ||
# Extract version from dry run output | ||
version=$(echo "$dry_run_output" | grep -o "The next release version is [0-9]\+\.[0-9]\+\.[0-9]\+" | cut -d ' ' -f6) | ||
if [ -z "$version" ]; then | ||
VERSION=$(echo "$DRY_OUTPUT" | grep -o "The next release version is [0-9]\+\.[0-9]\+\.[0-9]\+\(-rc\.[0-9]\+\)\?" | cut -d ' ' -f6) | ||
if [ -z "$VERSION" ]; then | ||
echo "Error: Could not determine version" | ||
exit 1 | ||
fi | ||
echo "new_release_version=$version" >> $GITHUB_OUTPUT | ||
echo "new_release_version=$VERSION" >> $GITHUB_OUTPUT | ||
# Run actual release | ||
if semantic-release; then | ||
echo "Release successful" | ||
echo "Successfully released version $VERSION" | ||
echo "new_release_published=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "Release failed" | ||
exit 1 | ||
fi | ||
env: | ||
CI: true | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
publish: | ||
needs: github_release | ||
|
@@ -79,7 +103,7 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
ref: ${{ github.ref }} | ||
|
||
- name: Install Rust | ||
uses: dtolnay/rust-toolchain@stable | ||
|
This file contains 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 |
---|---|---|
@@ -1,67 +1,65 @@ | ||
--- | ||
branches: | ||
- main | ||
tagFormat: ${version} | ||
- { name: main, prerelease: false, channel: latest } | ||
- { name: "rc/*", prerelease: rc, channel: rc } | ||
verifyConditions: | ||
- "@semantic-release/github" | ||
- "@semantic-release/git" | ||
|
||
plugins: | ||
- [ | ||
"@semantic-release/commit-analyzer", | ||
{ | ||
preset: "conventionalcommits", | ||
releaseRules: | ||
[ | ||
{ type: "feat", release: "minor" }, | ||
{ type: "impr", release: "patch" }, | ||
{ type: "refactor", release: "patch" }, | ||
{ type: "perf", release: "patch" }, | ||
{ type: "fix", release: "patch" }, | ||
{ type: "ci", release: "patch" }, | ||
{ type: "docs", release: "patch" }, | ||
{ type: "chore", release: "patch" }, | ||
{ type: "style", release: "patch" }, | ||
{ type: "test", release: "patch" }, | ||
{ type: "build", release: "patch" }, | ||
], | ||
}, | ||
] | ||
- [ | ||
"@semantic-release/release-notes-generator", | ||
{ | ||
preset: "conventionalcommits", | ||
presetConfig: | ||
{ | ||
types: | ||
[ | ||
{ type: "feat", section: "β¨ Features" }, | ||
{ type: "impr", section: "π Improvements" }, | ||
{ type: "refactor", section: "β»οΈ Improvements" }, | ||
{ type: "perf", section: "β‘οΈ Improvements" }, | ||
{ type: "fix", section: "π Bug Fixes" }, | ||
{ type: "ci", section: "π· CI" }, | ||
{ type: "docs", section: "π Documentation" }, | ||
{ type: "chore", section: "π§ Miscellaneous" }, | ||
{ type: "style", section: "π¨ Miscellaneous" }, | ||
{ type: "test", section: "β Miscellaneous" }, | ||
{ type: "build", section: "π¦ Miscellaneous" }, | ||
], | ||
}, | ||
}, | ||
] | ||
- ["@semantic-release/changelog", { "changelogFile": "CHANGELOG.md" }] | ||
- [ | ||
"@semantic-release/exec", | ||
{ | ||
"prepareCmd": 'sed -i ''s/^version = .*$/version = "${nextRelease.version}"/'' Cargo.toml && cargo check', | ||
}, | ||
] | ||
- [ | ||
"@semantic-release/github", | ||
{ | ||
"assets": ["CHANGELOG.md"], | ||
"releasedLabels": ["released"], | ||
"releaseNameTemplate": "π Version ${nextRelease.version}", | ||
}, | ||
] | ||
- [ | ||
"@semantic-release/git", | ||
{ "assets": ["CHANGELOG.md", "Cargo.lock", "Cargo.toml"] }, | ||
] | ||
- - "@semantic-release/commit-analyzer" | ||
- preset: "conventionalcommits" | ||
releaseRules: | ||
- { type: "feat", release: "minor" } | ||
- { type: "impr", release: "patch" } | ||
- { type: "refactor", release: "patch" } | ||
- { type: "perf", release: "patch" } | ||
- { type: "fix", release: "patch" } | ||
- { type: "ci", release: "patch" } | ||
- { type: "docs", release: "patch" } | ||
- { type: "style", release: "patch" } | ||
- { type: "test", release: "patch" } | ||
- { type: "build", release: "patch" } | ||
- { type: "chore", release: "patch", scope: "!release" } | ||
|
||
- - "@semantic-release/release-notes-generator" | ||
- preset: "conventionalcommits" | ||
presetConfig: | ||
types: | ||
- { type: "feat", section: "β¨ Features" } | ||
- { type: "impr", section: "π Improvements" } | ||
- { type: "refactor", section: "β»οΈ Improvements" } | ||
- { type: "perf", section: "β‘οΈ Improvements" } | ||
- { type: "fix", section: "π Bug Fixes" } | ||
- { type: "ci", section: "π· CI" } | ||
- { type: "docs", section: "π Documentation" } | ||
- { type: "chore", section: "π§ Miscellaneous" } | ||
- { type: "style", section: "π¨ Miscellaneous" } | ||
- { type: "test", section: "β Miscellaneous" } | ||
- { type: "build", section: "π¦ Miscellaneous" } | ||
|
||
- - "@semantic-release/changelog" | ||
- changelogFile: CHANGELOG.md | ||
changelogTitle: "# Changelog\n\nAll notable changes to this project will be documented in this file." | ||
verifyConditions: true | ||
|
||
- - "@semantic-release/exec" | ||
- verifyConditions: "cargo verify-project" | ||
prepareCmd: 'sed -i ''s/^version = .*$/version = "${nextRelease.version}"/'' Cargo.toml && cargo check' | ||
|
||
- - "@semantic-release/github" | ||
- assets: | ||
- CHANGELOG.md | ||
releasedLabels: ["released"] | ||
releaseNameTemplate: "π Version ${nextRelease.version}" | ||
successCommentCondition: "false" | ||
|
||
- - "@semantic-release/git" | ||
- assets: | ||
- CHANGELOG.md | ||
- Cargo.lock | ||
- Cargo.toml | ||
message: "chore(release): π ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" | ||
|
||
repositoryUrl: "https://github.com/inference-gateway/rust-sdk" | ||
tagFormat: "${version}" |