From 43ca5cd4c012f1dc355c6be7ea3f0ae6ee9cd14f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Triay?= Date: Mon, 29 Jan 2024 21:33:46 -0300 Subject: [PATCH] Add CI version bump (#862) * add prepare-release.yml * update changelog * fix replacement * fix current version extraction * add autocommit * fix autocommit * exclude package-lock and releasing from bump * fix exclusion * Update .github/workflows/prepare-release.yml * remove unused step ids * Update RELEASING.md Co-authored-by: Andrew Fleming * Update .github/workflows/prepare-release.yml Co-authored-by: Nikita Stupin <18281368+nikitastupin@users.noreply.github.com> * add GH_PAT to workflow * update secret name * update secret name * update secret name * fix PAT setting * Update .github/workflows/prepare-release.yml Co-authored-by: Andrew Fleming --------- Co-authored-by: Andrew Fleming Co-authored-by: Nikita Stupin <18281368+nikitastupin@users.noreply.github.com> --- .github/workflows/prepare-release.yml | 34 +++++++++++++++++++++++++++ CHANGELOG.md | 1 + RELEASING.md | 12 +++++----- 3 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/prepare-release.yml diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml new file mode 100644 index 000000000..49164cae8 --- /dev/null +++ b/.github/workflows/prepare-release.yml @@ -0,0 +1,34 @@ +name: Update version on new release branch + +on: + create: + +jobs: + update_version: + if: github.ref_type == 'branch' && startsWith(github.ref, 'refs/heads/release-v') + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + token: ${{ secrets.OPENZEPPELIN_ORG_GITHUB_PAT }} + + - name: Extract current version + run: | + CURRENT_VERSION=$(grep '^version = ' Scarb.toml | sed 's/version = "\(.*\)"/\1/') + echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV + + - name: Extract new version number + run: echo "NEW_VERSION=${GITHUB_REF#refs/heads/release-v}" >> $GITHUB_ENV + + - name: Replace version in files + run: | + echo "Current version: $CURRENT_VERSION" + echo "New version: $NEW_VERSION" + find . -type f -not -path '*/\.*' -not -path './CHANGELOG.md' -not -path './docs/package-lock.json' -not -path './RELEASING.md' -exec sed -i "s/$CURRENT_VERSION/$NEW_VERSION/g" {} + + + - name: Auto-commit changes + uses: stefanzweifel/git-auto-commit-action@3ea6ae190baf489ba007f7c92608f33ce20ef04a #v4.16.0 + with: + commit_message: Bump version to ${{ env.NEW_VERSION }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 44796a95b..32f8cac09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Utilities documentation (#825) - Documentation for presets (#832) - Backwards compatibility notice (#861) +- Add automatic version bump to CI (#862) ### Changed diff --git a/RELEASING.md b/RELEASING.md index 03c503d9c..2a3540cb7 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -8,22 +8,22 @@ git checkout -b release-v0.8.0 ``` -(3) Search and replace the current release version with the one to be released (e.g. `0.7.0` to `0.8.0`, or `0.8.0-beta.0` to `0.8.0-beta.1`). +(3) Create the release entry in [the changelog](CHANGELOG.md) with the contents of the _Unreleased_ section, which should be left empty. -(4) Create the release entry in [the changelog](CHANGELOG.md) with the contents of the _Unreleased_ section, which should be left empty. - -(5) Push and open a PR targeting `main` to carefully review the release changes. +(4) Push and open a PR targeting `main` to carefully review the release changes. This will trigger a Github workflow that automatically bumps the version number throughout the project. ```sh git push release-v0.8.0 ``` -(6) Once merged, create a tag on the release branch and push it to the main repository. +(5) Once merged, pull the changes from the release branch. +Then, create a tag on the release branch and push it to the main repository. ```sh +git pull git tag v0.8.0 git push origin v0.8.0 ``` -(7) Finally, go to the repo's [releases page](https://github.com/OpenZeppelin/cairo-contracts/releases/) and [create a new one](https://github.com/OpenZeppelin/cairo-contracts/releases/new) with the new tag and the base branch as target (`main` except in the event of a hotfix). +(6) Finally, go to the repo's [releases page](https://github.com/OpenZeppelin/cairo-contracts/releases/) and [create a new one](https://github.com/OpenZeppelin/cairo-contracts/releases/new) with the new tag and the base branch as target (`main` except in the event of a hotfix). Make sure to write a detailed release description and a short changelog.