Skip to content

Commit

Permalink
Rework release CI to avoid directly commiting to master (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeicor authored Jan 12, 2025
1 parent d473217 commit bac310a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -ex
# This needs to be done in a new branch as master is protected
export VERSION="${GITHUB_REF##*/}"
git checkout -b "update-cargo-version-${VERSION:1}"
echo "BRANCH_NAME=update-cargo-version-${VERSION:1}" >> $GITHUB_OUTPUT
export BRANCH_NAME="update-cargo-version-${VERSION:1}"
git checkout -b "${BRANCH_NAME}"
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
# Actually update the Cargo.toml
sed -E -i "s/^version = \"[^\"]*\"/version = \"${VERSION:1}\"/g" Cargo.toml # e.g. v0.0.1 -> version = "0.0.1"
Expand All @@ -59,8 +62,10 @@ jobs:
git tag -d "${VERSION}"
git tag "${VERSION}"
# Push the new branch and tag
git push --tags origin "${VERSION}"
# Push the new branch and overwrite the old tag
git push origin "${VERSION}"
git push -d origin "${BRANCH_NAME}"
git push origin "${BRANCH_NAME}"
# Open a pull request that will automatically merge after the CI passes
gh pr create --base master --head "update-cargo-version-${VERSION:1}" --title "Update Cargo.toml to version ${VERSION:1}" --body "This PR updates the version in Cargo.toml to ${VERSION:1} and moves the release tag to the commit."
Expand Down

0 comments on commit bac310a

Please sign in to comment.