From cd64e761f34be30408bbab7a18c82b6aa8fddc8f Mon Sep 17 00:00:00 2001 From: James Edwards Date: Tue, 21 Nov 2023 16:50:01 -0700 Subject: [PATCH 1/6] add version.txt and pre-push hook --- checkout_externals | 9 ++++++++- manic/checkout.py | 3 +++ version.txt | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 version.txt diff --git a/checkout_externals b/checkout_externals index 48bce24..536c64e 100755 --- a/checkout_externals +++ b/checkout_externals @@ -12,7 +12,7 @@ from __future__ import print_function import sys import traceback - +import os import manic if sys.hexversion < 0x02070000: @@ -26,6 +26,13 @@ if sys.hexversion < 0x02070000: if __name__ == '__main__': ARGS = manic.checkout.commandline_arguments() + if ARGS.version: + version_info = '' + version_file_path = os.path.join(os.path.dirname(__file__),'version.txt') + with open(version_file_path) as f: + version_info = f.readlines()[0].strip() + print(version_info) + sys.exit(0) try: RET_STATUS, _ = manic.checkout.main(ARGS) sys.exit(RET_STATUS) diff --git a/manic/checkout.py b/manic/checkout.py index 3f5537a..25c05ea 100755 --- a/manic/checkout.py +++ b/manic/checkout.py @@ -304,6 +304,9 @@ def commandline_arguments(args=None): 'used up to two times, increasing the ' 'verbosity level each time.') + parser.add_argument('--version', action='store_true', default=False, + help='Print manage_externals version and exit.') + parser.add_argument('--svn-ignore-ancestry', action='store_true', default=False, help='By default, subversion will abort if a component is ' 'already checked out and there is no common ancestry with ' diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..22de17a --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +manic-1.2.23 From 757fed1c2555fbc99c135e1f52e7ac04ea6aa199 Mon Sep 17 00:00:00 2001 From: James Edwards Date: Tue, 21 Nov 2023 16:50:56 -0700 Subject: [PATCH 2/6] update version.txt --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index 22de17a..db2a093 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -manic-1.2.23 +manic-1.2.23-1-gcd64e76 From 3d13177119749e31d5a1f026106513434b5de96f Mon Sep 17 00:00:00 2001 From: James Edwards Date: Tue, 21 Nov 2023 16:58:51 -0700 Subject: [PATCH 3/6] update version.txt --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index db2a093..cbda54c 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -manic-1.2.23-1-gcd64e76 +manic-1.2.24-3-gba00e50 From cb06623fca1dfab432ec860cb4cac24e6a9eb679 Mon Sep 17 00:00:00 2001 From: James Edwards Date: Tue, 21 Nov 2023 17:09:42 -0700 Subject: [PATCH 4/6] use github workflow to update version.txt --- .github/workflows/bumpversion.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bumpversion.yml b/.github/workflows/bumpversion.yml index f4dc9b7..fc1e1ca 100644 --- a/.github/workflows/bumpversion.yml +++ b/.github/workflows/bumpversion.yml @@ -10,10 +10,20 @@ jobs: - uses: actions/checkout@v3 - name: Bump version and push tag id: tag_version - uses: mathieudutour/github-tag-action@v5.5 + uses: mathieudutour/github-tag-action@v6.1 with: github_token: ${{ secrets.GITHUB_TOKEN }} create_annotated_tag: true default_bump: patch dry_run: false tag_prefix: manic- + write-version: + runs-on: ubuntu-latest + name: Write Version to File + steps: + - uses: actions/checkout@master + - name: Update version + uses: brettdorrans/write-version-to-file@v1.0.2 + with: + filename: '/.version.txt' + placeholder: '${VERSION}' From 1506bbf35260a60e19f7bfc3f8b33fb9f2437e0f Mon Sep 17 00:00:00 2001 From: James Edwards Date: Wed, 22 Nov 2023 06:34:38 -0700 Subject: [PATCH 5/6] Need to update file before creating version --- .github/workflows/bumpversion.yml | 47 +++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/.github/workflows/bumpversion.yml b/.github/workflows/bumpversion.yml index fc1e1ca..62418b9 100644 --- a/.github/workflows/bumpversion.yml +++ b/.github/workflows/bumpversion.yml @@ -1,15 +1,42 @@ -name: Bump version +name: Update file on PR merge on: - push: + pull_request: branches: - main + types: closed + jobs: - build: + update_date: + if: github.event.pull_request.merged == true runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: checkout + uses: actions/checkout@v3 + with: + # Fetch full depth, otherwise the last step overwrites the last commit's parent, essentially removing the graph. + fetch-depth: 0 + + - name: GenerateTag + id: name_tag + uses: mathieudutour/github-tag-action@v6.1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + create_annotated_tag: true + default_bump: patch + dry_run: true + tag_prefix: manic- + - name: Update version.txt + run: | + echo "${{ steps.name_tag.outputs.new_tag }}" > version.txt + - name: Amend the last commit + run: | + git config --global user.email "gitbot@openrct2.org" + git config --global user.name "OpenRCT2 git bot" + git commit -a --amend --no-edit + git push --force-with-lease + echo "Complete"name: Bump version - name: Bump version and push tag - id: tag_version + id: really_tag_version uses: mathieudutour/github-tag-action@v6.1 with: github_token: ${{ secrets.GITHUB_TOKEN }} @@ -17,13 +44,3 @@ jobs: default_bump: patch dry_run: false tag_prefix: manic- - write-version: - runs-on: ubuntu-latest - name: Write Version to File - steps: - - uses: actions/checkout@master - - name: Update version - uses: brettdorrans/write-version-to-file@v1.0.2 - with: - filename: '/.version.txt' - placeholder: '${VERSION}' From 46b2eb9181f3a355436e80b97e56f26988ca6e44 Mon Sep 17 00:00:00 2001 From: James Edwards Date: Wed, 22 Nov 2023 07:18:44 -0700 Subject: [PATCH 6/6] improve workflow name --- .github/workflows/bumpversion.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bumpversion.yml b/.github/workflows/bumpversion.yml index 62418b9..a37084a 100644 --- a/.github/workflows/bumpversion.yml +++ b/.github/workflows/bumpversion.yml @@ -6,7 +6,7 @@ on: types: closed jobs: - update_date: + update_version: if: github.event.pull_request.merged == true runs-on: ubuntu-latest steps: