From deeba8b21c45597dcd4a001eb7ef9b44675fb390 Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 21 Jul 2022 17:11:08 -0400 Subject: [PATCH 01/18] add update_version script --- scripts/update_version.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 scripts/update_version.py diff --git a/scripts/update_version.py b/scripts/update_version.py new file mode 100644 index 000000000..037a33a55 --- /dev/null +++ b/scripts/update_version.py @@ -0,0 +1,23 @@ +import sys +import fileinput +from pathlib import Path + +CURRENT_VERSION = "v0.2.1" + + +def main(): + new_version = str(sys.argv[1]) + path = Path('src') + for p in path.glob(f"**/*.cairo"): + _update_version(p, new_version) + _update_version("scripts/update_version.py", new_version) + +def _update_version(path, version): + with fileinput.input(path, inplace=True) as file: + for line in file: + new_line = line.replace(CURRENT_VERSION, version) + print(new_line, end="") + + +if __name__ == "__main__": + main() \ No newline at end of file From ecab3cd07740ebc4d285ba04a8a1d72fff0094f4 Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 21 Jul 2022 17:11:33 -0400 Subject: [PATCH 02/18] add script to checklist --- RELEASING.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/RELEASING.md b/RELEASING.md index 2cc4c85fc..3c77153f5 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -4,7 +4,13 @@ Releasing checklist: (1) Write a changelog. -(2) Make sure to update SPDX license identifiers. For example: +(2) Run the `update_version` script to update the SPDX license identifiers for all Cairo contracts in the `src` directory. For example: + +```bash +python3 scripts/update_version.py v0.2.0 +``` + +changes: ```cairo # SPDX-License-Identifier: MIT @@ -18,6 +24,8 @@ to # OpenZeppelin Contracts for Cairo v0.2.0 (account/Account.cairo) ``` +> Note: save and merge changes before releasing! + (3) Create a release branch and add a tag to it. This branch can be useful if we need to push a hot fix on top of an existing release in the case of a bug. ```sh From 48c0972315510ca48b1534c7d512b3e10dbbd0cf Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 21 Jul 2022 17:14:42 -0400 Subject: [PATCH 03/18] fix glob --- scripts/update_version.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/update_version.py b/scripts/update_version.py index 037a33a55..79f67a2be 100644 --- a/scripts/update_version.py +++ b/scripts/update_version.py @@ -7,8 +7,8 @@ def main(): new_version = str(sys.argv[1]) - path = Path('src') - for p in path.glob(f"**/*.cairo"): + path = Path("src") + for p in path.glob("**/*.cairo"): _update_version(p, new_version) _update_version("scripts/update_version.py", new_version) From 4d5e9d5ac3e99ef9d662fcbc293cb7a10165ab6f Mon Sep 17 00:00:00 2001 From: Andrew Date: Sun, 24 Jul 2022 18:02:55 -0400 Subject: [PATCH 04/18] add line --- scripts/update_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update_version.py b/scripts/update_version.py index 79f67a2be..c9d9114ab 100644 --- a/scripts/update_version.py +++ b/scripts/update_version.py @@ -20,4 +20,4 @@ def _update_version(path, version): if __name__ == "__main__": - main() \ No newline at end of file + main() From 1f99f47f17e8340440c47af13052cba66d6b003d Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 30 Jul 2022 04:49:04 -0400 Subject: [PATCH 05/18] add antora path to script --- scripts/update_version.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/update_version.py b/scripts/update_version.py index c9d9114ab..154f0b273 100644 --- a/scripts/update_version.py +++ b/scripts/update_version.py @@ -1,8 +1,9 @@ -import sys import fileinput +import sys from pathlib import Path CURRENT_VERSION = "v0.2.1" +ANTORA_PATH = "docs/antora.yml" def main(): @@ -10,12 +11,18 @@ def main(): path = Path("src") for p in path.glob("**/*.cairo"): _update_version(p, new_version) + _update_version(ANTORA_PATH, new_version) _update_version("scripts/update_version.py", new_version) + def _update_version(path, version): with fileinput.input(path, inplace=True) as file: for line in file: - new_line = line.replace(CURRENT_VERSION, version) + old, new = CURRENT_VERSION, version + if path == ANTORA_PATH: + old = old.strip("v") + new = new.strip("v") + new_line = line.replace(old, new) print(new_line, end="") From 679afb1c7779f48788a119046d197f440f73914c Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 30 Jul 2022 04:49:42 -0400 Subject: [PATCH 06/18] add version bump job --- .github/workflows/python-app.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 82be7e62d..59f4f9aad 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -12,6 +12,23 @@ on: types: [published] jobs: + version: + runs-on: ubuntu-latest + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') + steps: + - name: Checkout main branch + uses: actions/checkout@v3 + with: + ref: 'main' + - name: Print version + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Iterate and bump version + run: python scripts/update_version.py ${{ env.RELEASE_VERSION }} + - name: Auto-commit changes + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Apply version bump + test: runs-on: ubuntu-latest steps: From 7eebefefc64439c37110cc170982a3b78cc16fa4 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 30 Jul 2022 14:35:18 -0400 Subject: [PATCH 07/18] add version dep --- .github/workflows/python-app.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 59f4f9aad..39822fa38 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -31,6 +31,8 @@ jobs: test: runs-on: ubuntu-latest + if: ${{ always() }} + needs: [version] steps: - uses: actions/checkout@v2 - name: Markdown Linter From 03201783bcd01fa4540c241ea8d2f84d4975d204 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 30 Jul 2022 14:59:26 -0400 Subject: [PATCH 08/18] update RELEASING with new CI workflow --- RELEASING.md | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/RELEASING.md b/RELEASING.md index 3c77153f5..9175006e4 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -4,36 +4,16 @@ Releasing checklist: (1) Write a changelog. -(2) Run the `update_version` script to update the SPDX license identifiers for all Cairo contracts in the `src` directory. For example: - -```bash -python3 scripts/update_version.py v0.2.0 -``` - -changes: - -```cairo -# SPDX-License-Identifier: MIT -# OpenZeppelin Contracts for Cairo v0.1.0 (account/Account.cairo) -``` - -to - -```cairo -# SPDX-License-Identifier: MIT -# OpenZeppelin Contracts for Cairo v0.2.0 (account/Account.cairo) -``` - -> Note: save and merge changes before releasing! - -(3) Create a release branch and add a tag to it. This branch can be useful if we need to push a hot fix on top of an existing release in the case of a bug. +(2) Create a release branch and add a tag to it. This branch can be useful if we need to push a hot fix on top of an existing release in the case of a bug. ```sh git checkout -b release-0.2.0 git tag v0.2.0 ``` -(4) Push the tag to the main repository, [triggering the CI and release process](https://github.com/OpenZeppelin/cairo-contracts/blob/b27101eb826fae73f49751fa384c2a0ff3377af2/.github/workflows/python-app.yml#L60). +(3) Push the tag to the main repository, [triggering the CI and release process](https://github.com/OpenZeppelin/cairo-contracts/blob/b27101eb826fae73f49751fa384c2a0ff3377af2/.github/workflows/python-app.yml#L60). + +> Note that the CI automatically updates the SPDX identifiers with the pushed tag. ```sh git push origin v0.2.0 From 188871e90ae70d06ed6e0b25d58884c2ff0ba0b6 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sun, 31 Jul 2022 13:31:42 -0400 Subject: [PATCH 09/18] add token for checkout --- .github/workflows/python-app.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 39822fa38..288e76c9a 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -20,9 +20,10 @@ jobs: uses: actions/checkout@v3 with: ref: 'main' - - name: Print version + #token: ${{ secrets. }} + - name: Set version run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - name: Iterate and bump version + - name: Run script run: python scripts/update_version.py ${{ env.RELEASE_VERSION }} - name: Auto-commit changes uses: stefanzweifel/git-auto-commit-action@v4 From c10dafb9f4c36d83fd1e251b6d35b4c758b7fd4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Triay?= Date: Wed, 3 Aug 2022 23:05:06 +0200 Subject: [PATCH 10/18] Update .github/workflows/python-app.yml Co-authored-by: Francisco --- .github/workflows/python-app.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 288e76c9a..d97f39e54 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -20,7 +20,7 @@ jobs: uses: actions/checkout@v3 with: ref: 'main' - #token: ${{ secrets. }} + ssh-key: ${{ secrets.SSH_KEY }} - name: Set version run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - name: Run script From 7d954ece7bceb9ac27b1f02b14a36a1f3a51dcd9 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 3 Aug 2022 22:42:02 -0400 Subject: [PATCH 11/18] change dep tag to commit hash --- .github/workflows/python-app.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 288e76c9a..2b375aa59 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -26,7 +26,7 @@ jobs: - name: Run script run: python scripts/update_version.py ${{ env.RELEASE_VERSION }} - name: Auto-commit changes - uses: stefanzweifel/git-auto-commit-action@v4 + uses: stefanzweifel/git-auto-commit-action@49620cd3ed21ee620a48530e81dba0d139c9cb80 with: commit_message: Apply version bump From 9d3f943828b5469e6bc829d74ec9558d8f358d13 Mon Sep 17 00:00:00 2001 From: Andrew Fleming Date: Wed, 3 Aug 2022 22:44:33 -0400 Subject: [PATCH 12/18] Update .github/workflows/python-app.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Martín Triay --- .github/workflows/python-app.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 06da4ba76..0d751853c 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -23,7 +23,7 @@ jobs: ssh-key: ${{ secrets.SSH_KEY }} - name: Set version run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - name: Run script + - name: Update version run: python scripts/update_version.py ${{ env.RELEASE_VERSION }} - name: Auto-commit changes uses: stefanzweifel/git-auto-commit-action@49620cd3ed21ee620a48530e81dba0d139c9cb80 From 29766688199bc3152a4836c005982c1f9a8e3fff Mon Sep 17 00:00:00 2001 From: Andrew Fleming Date: Thu, 4 Aug 2022 11:51:50 -0400 Subject: [PATCH 13/18] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Martín Triay --- .github/workflows/python-app.yml | 3 +++ RELEASING.md | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 0d751853c..fa993d834 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -29,6 +29,9 @@ jobs: uses: stefanzweifel/git-auto-commit-action@49620cd3ed21ee620a48530e81dba0d139c9cb80 with: commit_message: Apply version bump + create_branch: true + branch: release-${{ env.RELEASE_VERSION }} + tagging_message: ${{ env.RELEASE_VERSION }} test: runs-on: ubuntu-latest diff --git a/RELEASING.md b/RELEASING.md index 9175006e4..9eb07c449 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -4,16 +4,17 @@ Releasing checklist: (1) Write a changelog. -(2) Create a release branch and add a tag to it. This branch can be useful if we need to push a hot fix on top of an existing release in the case of a bug. +(2) Create a tag for the release. ```sh -git checkout -b release-0.2.0 git tag v0.2.0 ``` (3) Push the tag to the main repository, [triggering the CI and release process](https://github.com/OpenZeppelin/cairo-contracts/blob/b27101eb826fae73f49751fa384c2a0ff3377af2/.github/workflows/python-app.yml#L60). -> Note that the CI automatically updates the SPDX identifiers with the pushed tag. +> Note that the CI automatically: +- Updates the SPDX identifiers and antora.yml versions with the pushed tag +- Creates a release branch and adds a tag to it. This can be useful if we need to push a hot fix on top of an existing release in the case of a bug. ```sh git push origin v0.2.0 From 2f4ed689c3748f2a08fbb6b60501a905c87fe806 Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 4 Aug 2022 11:54:03 -0400 Subject: [PATCH 14/18] merge release branch to main in version job --- .github/workflows/python-app.yml | 6 +++++- RELEASING.md | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index fa993d834..39b42f467 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -31,7 +31,11 @@ jobs: commit_message: Apply version bump create_branch: true branch: release-${{ env.RELEASE_VERSION }} - tagging_message: ${{ env.RELEASE_VERSION }} + - name: Merge changes to main + run: | + git checkout "main" + git merge "release-${{ env.RELEASE_VERSION }}" --no-edit + git push test: runs-on: ubuntu-latest diff --git a/RELEASING.md b/RELEASING.md index 9eb07c449..df7fd7a60 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -13,6 +13,7 @@ git tag v0.2.0 (3) Push the tag to the main repository, [triggering the CI and release process](https://github.com/OpenZeppelin/cairo-contracts/blob/b27101eb826fae73f49751fa384c2a0ff3377af2/.github/workflows/python-app.yml#L60). > Note that the CI automatically: + - Updates the SPDX identifiers and antora.yml versions with the pushed tag - Creates a release branch and adds a tag to it. This can be useful if we need to push a hot fix on top of an existing release in the case of a bug. From b687c181da28e5551a0013f9fc625fb8bd7b956f Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 4 Aug 2022 18:41:46 -0400 Subject: [PATCH 15/18] fix git push format --- RELEASING.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/RELEASING.md b/RELEASING.md index df7fd7a60..2d71d25c8 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -12,11 +12,11 @@ git tag v0.2.0 (3) Push the tag to the main repository, [triggering the CI and release process](https://github.com/OpenZeppelin/cairo-contracts/blob/b27101eb826fae73f49751fa384c2a0ff3377af2/.github/workflows/python-app.yml#L60). +```sh +git push origin v0.2.0 +``` + > Note that the CI automatically: - Updates the SPDX identifiers and antora.yml versions with the pushed tag - Creates a release branch and adds a tag to it. This can be useful if we need to push a hot fix on top of an existing release in the case of a bug. - -```sh -git push origin v0.2.0 -``` From a2e8cac166dd54aac9a5f5d16c76c250353469ac Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 4 Aug 2022 18:43:39 -0400 Subject: [PATCH 16/18] remove blockquote --- RELEASING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASING.md b/RELEASING.md index 2d71d25c8..570c49c66 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -16,7 +16,7 @@ git tag v0.2.0 git push origin v0.2.0 ``` -> Note that the CI automatically: +Note that the CI automatically: - Updates the SPDX identifiers and antora.yml versions with the pushed tag - Creates a release branch and adds a tag to it. This can be useful if we need to push a hot fix on top of an existing release in the case of a bug. From 62084231fa6202434afb67b74d68f875307a7f27 Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 4 Aug 2022 19:16:01 -0400 Subject: [PATCH 17/18] add branch checkout to checklist --- RELEASING.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/RELEASING.md b/RELEASING.md index 570c49c66..aa9c322d8 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -4,13 +4,15 @@ Releasing checklist: (1) Write a changelog. -(2) Create a tag for the release. +(2) Checkout the branch to be released. This should be `main` except in the event of a hotfix. For hotfixes, checkout the release branch. + +(3) Create a tag for the release. ```sh git tag v0.2.0 ``` -(3) Push the tag to the main repository, [triggering the CI and release process](https://github.com/OpenZeppelin/cairo-contracts/blob/b27101eb826fae73f49751fa384c2a0ff3377af2/.github/workflows/python-app.yml#L60). +(4) Push the tag to the main repository, [triggering the CI and release process](https://github.com/OpenZeppelin/cairo-contracts/blob/b27101eb826fae73f49751fa384c2a0ff3377af2/.github/workflows/python-app.yml#L60). ```sh git push origin v0.2.0 From c290e71bd8a5e6f98d19d92f0dcf1d6efd1fcffb Mon Sep 17 00:00:00 2001 From: Andrew Fleming Date: Thu, 4 Aug 2022 19:32:09 -0400 Subject: [PATCH 18/18] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Martín Triay --- .github/workflows/python-app.yml | 2 +- RELEASING.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 39b42f467..75dff67f1 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -28,7 +28,7 @@ jobs: - name: Auto-commit changes uses: stefanzweifel/git-auto-commit-action@49620cd3ed21ee620a48530e81dba0d139c9cb80 with: - commit_message: Apply version bump + commit_message: Bump version to ${{ env.RELEASE_VERSION }} create_branch: true branch: release-${{ env.RELEASE_VERSION }} - name: Merge changes to main diff --git a/RELEASING.md b/RELEASING.md index aa9c322d8..45c3c6879 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -4,7 +4,7 @@ Releasing checklist: (1) Write a changelog. -(2) Checkout the branch to be released. This should be `main` except in the event of a hotfix. For hotfixes, checkout the release branch. +(2) Checkout the branch to be released. This should be `main` except in the event of a hotfix. For hotfixes, checkout the latest release branch. (3) Create a tag for the release.