diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml new file mode 100644 index 000000000..73ac620b9 --- /dev/null +++ b/.github/workflows/prepare-release.yml @@ -0,0 +1,30 @@ +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 + + - name: Extract current version + id: 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 + id: new-version + run: echo "NEW_VERSION=${GITHUB_REF#refs/heads/release-v}" >> $GITHUB_ENV + + - name: Replace version in files + run: | + echo "Current version: ${{ env.CURRENT_VERSION }}" + echo "New version: ${{ env.NEW_VERSION }}" + find . -type f -not -path '*/\.*' -exec sed -i "s/${{ env.CURRENT_VERSION }}/${{ env.NEW_VERSION }}/g" {} + + find . -type f -not -path '*/\.*' -not -name 'CHANGELOG.md' -exec sed -i "s/${{ env.CURRENT_VERSION }}/${{ env.NEW_VERSION }}/g" {} + diff --git a/RELEASING.md b/RELEASING.md index 03c503d9c..dc9876401 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -8,22 +8,20 @@ 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, create a tag on the release branch and push it to the main repository. ```sh 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.