From 61a99148627475bf81744019ea2cc15466bab50b Mon Sep 17 00:00:00 2001 From: "David W.H. Swenson" Date: Wed, 12 May 2021 21:16:02 +0200 Subject: [PATCH 1/4] Vendored workflows are templates In particular, this allows us to attach a version to the workflows, but still keep that version information in a single source of truth. --- .github/workflows/autorelease-default-env.sh | 4 +++- .github/workflows/autorelease-deploy.yml | 2 ++ .github/workflows/autorelease-gh-rel.yml | 2 ++ .github/workflows/autorelease-prep.yml | 4 ++-- .../gh_actions_stages/autorelease-default-env.sh | 4 +++- .../gh_actions_stages/autorelease-deploy.yml | 8 +++++--- .../gh_actions_stages/autorelease-gh-rel.yml | 12 +++++++----- .../gh_actions_stages/autorelease-prep.yml | 16 ++++++++-------- autorelease/scripts/vendor.py | 15 ++++++++++----- 9 files changed, 42 insertions(+), 25 deletions(-) diff --git a/.github/workflows/autorelease-default-env.sh b/.github/workflows/autorelease-default-env.sh index 064478c..f15ac5c 100644 --- a/.github/workflows/autorelease-default-env.sh +++ b/.github/workflows/autorelease-default-env.sh @@ -1,4 +1,6 @@ -INSTALL_AUTORELEASE="python -m pip install autorelease==0.3.0" +# Vendored from Autorelease 0.3.1 +# Update by updating Autorelease and running `autorelease vendor actions` +INSTALL_AUTORELEASE="python -m pip install autorelease==0.3.1" if [ -f autorelease-env.sh ]; then source autorelease-env.sh fi diff --git a/.github/workflows/autorelease-deploy.yml b/.github/workflows/autorelease-deploy.yml index 5192236..f30139c 100644 --- a/.github/workflows/autorelease-deploy.yml +++ b/.github/workflows/autorelease-deploy.yml @@ -1,3 +1,5 @@ +# Vendored from Autorelease 0.3.1 +# Update by updating Autorelease and running `autorelease vendor actions` name: Autorelease on: release: diff --git a/.github/workflows/autorelease-gh-rel.yml b/.github/workflows/autorelease-gh-rel.yml index 32cd720..0d17f90 100644 --- a/.github/workflows/autorelease-gh-rel.yml +++ b/.github/workflows/autorelease-gh-rel.yml @@ -1,3 +1,5 @@ +# Vendored from Autorelease 0.3.1 +# Update by updating Autorelease and running `autorelease vendor actions` name: Autorelease on: push: diff --git a/.github/workflows/autorelease-prep.yml b/.github/workflows/autorelease-prep.yml index ae965dc..3fc009d 100644 --- a/.github/workflows/autorelease-prep.yml +++ b/.github/workflows/autorelease-prep.yml @@ -1,5 +1,5 @@ -# File vencdored from Autorelease; specific version information should be in -# the INSTALL_AUTORELEASE variable in autorelease-default-env.sh +# Vendored from Autorelease 0.3.1 +# Update by updating Autorelease and running `autorelease vendor actions` name: "Autorelease" on: pull_request: diff --git a/autorelease/gh_actions_stages/autorelease-default-env.sh b/autorelease/gh_actions_stages/autorelease-default-env.sh index 064478c..2b62a7e 100644 --- a/autorelease/gh_actions_stages/autorelease-default-env.sh +++ b/autorelease/gh_actions_stages/autorelease-default-env.sh @@ -1,4 +1,6 @@ -INSTALL_AUTORELEASE="python -m pip install autorelease==0.3.0" +# Vendored from Autorelease $VERSION +# Update by updating Autorelease and running `autorelease vendor actions` +INSTALL_AUTORELEASE="python -m pip install autorelease==$VERSION" if [ -f autorelease-env.sh ]; then source autorelease-env.sh fi diff --git a/autorelease/gh_actions_stages/autorelease-deploy.yml b/autorelease/gh_actions_stages/autorelease-deploy.yml index 5192236..08b643c 100644 --- a/autorelease/gh_actions_stages/autorelease-deploy.yml +++ b/autorelease/gh_actions_stages/autorelease-deploy.yml @@ -1,3 +1,5 @@ +# Vendored from Autorelease $VERSION +# Update by updating Autorelease and running `autorelease vendor actions` name: Autorelease on: release: @@ -15,12 +17,12 @@ jobs: - run: | # TODO: move this to an action source ./.github/workflows/autorelease-default-env.sh if [ -f "autorelease-env.sh" ]; then - cat autorelease-env.sh >> $GITHUB_ENV + cat autorelease-env.sh >> $$GITHUB_ENV fi if [ -f "./.autorelease/install-autorelease" ]; then source ./.autorelease/install-autorelease else - eval $INSTALL_AUTORELEASE + eval $$INSTALL_AUTORELEASE fi name: "Install autorelease" - run: | @@ -32,6 +34,6 @@ jobs: name: "Build and check package" - uses: pypa/gh-action-pypi-publish@master with: - password: ${{ secrets.pypi_password }} + password: $${{ secrets.pypi_password }} name: "Deploy to pypi" diff --git a/autorelease/gh_actions_stages/autorelease-gh-rel.yml b/autorelease/gh_actions_stages/autorelease-gh-rel.yml index 32cd720..1809fee 100644 --- a/autorelease/gh_actions_stages/autorelease-gh-rel.yml +++ b/autorelease/gh_actions_stages/autorelease-gh-rel.yml @@ -1,3 +1,5 @@ +# Vendored from Autorelease $VERSION +# Update by updating Autorelease and running `autorelease vendor actions` name: Autorelease on: push: @@ -16,18 +18,18 @@ jobs: - run: | # TODO: move this to an action source ./.github/workflows/autorelease-default-env.sh if [ -f "autorelease-env.sh" ]; then - cat autorelease-env.sh >> $GITHUB_ENV + cat autorelease-env.sh >> $$GITHUB_ENV fi if [ -f "./.autorelease/install-autorelease" ]; then source ./.autorelease/install-autorelease else - eval $INSTALL_AUTORELEASE + eval $$INSTALL_AUTORELEASE fi name: "Install autorelease" - run: | VERSION=`python setup.py --version` PROJECT=`python setup.py --name` - echo $PROJECT $VERSION - autorelease-release --project $PROJECT --version $VERSION --token $AUTORELEASE_TOKEN + echo $$PROJECT $$VERSION + autorelease-release --project $$PROJECT --version $$VERSION --token $$AUTORELEASE_TOKEN env: - AUTORELEASE_TOKEN: ${{ secrets.AUTORELEASE_TOKEN }} + AUTORELEASE_TOKEN: $${{ secrets.AUTORELEASE_TOKEN }} diff --git a/autorelease/gh_actions_stages/autorelease-prep.yml b/autorelease/gh_actions_stages/autorelease-prep.yml index ae965dc..c3e8086 100644 --- a/autorelease/gh_actions_stages/autorelease-prep.yml +++ b/autorelease/gh_actions_stages/autorelease-prep.yml @@ -1,5 +1,5 @@ -# File vencdored from Autorelease; specific version information should be in -# the INSTALL_AUTORELEASE variable in autorelease-default-env.sh +# Vendored from Autorelease $VERSION +# Update by updating Autorelease and running `autorelease vendor actions` name: "Autorelease" on: pull_request: @@ -22,12 +22,12 @@ jobs: - run: | # TODO: move this to an action source ./.github/workflows/autorelease-default-env.sh if [ -f "autorelease-env.sh" ]; then - cat autorelease-env.sh >> $GITHUB_ENV + cat autorelease-env.sh >> $$GITHUB_ENV fi if [ -f "./.autorelease/install-autorelease" ]; then source ./.autorelease/install-autorelease else - eval $INSTALL_AUTORELEASE + eval $$INSTALL_AUTORELEASE fi name: "Install autorelease" - run: | @@ -43,7 +43,7 @@ jobs: name: "Build and check package" - uses: pypa/gh-action-pypi-publish@master with: - password: ${{ secrets.testpypi_password }} + password: $${{ secrets.testpypi_password }} repository_url: https://test.pypi.org/legacy/ name: "Deploy to testpypi" test_testpypi: @@ -58,12 +58,12 @@ jobs: - run: | # TODO: move this to an action source ./.github/workflows/autorelease-default-env.sh if [ -f "autorelease-env.sh" ]; then - cat autorelease-env.sh >> $GITHUB_ENV + cat autorelease-env.sh >> $$GITHUB_ENV fi if [ -f "./.autorelease/install-autorelease" ]; then source ./.autorelease/install-autorelease else - eval $INSTALL_AUTORELEASE + eval $$INSTALL_AUTORELEASE fi name: "Install autorelease" - name: "Install testpypi version" @@ -71,6 +71,6 @@ jobs: - name: "Test testpypi version" run: | if [ -f "autorelease-env.sh" ]; then - cat autorelease-env.sh >> $GITHUB_ENV + cat autorelease-env.sh >> $$GITHUB_ENV fi test-testpypi diff --git a/autorelease/scripts/vendor.py b/autorelease/scripts/vendor.py index 787415d..8e19a5a 100644 --- a/autorelease/scripts/vendor.py +++ b/autorelease/scripts/vendor.py @@ -1,8 +1,8 @@ -import pkg_resources +import string import pathlib -import shutil - -import click +import pkg_resources +from packaging.version import Version +import autorelease def vendor(resources, base_path, relative_target_dir): for resource in resources: @@ -12,7 +12,12 @@ def vendor(resources, base_path, relative_target_dir): target_dir.mkdir(parents=True, exist_ok=True) target_loc = base_path / relative_target_dir / name # print(f"cp {orig_loc} {target_loc}") - shutil.copy(orig_loc, target_loc) + with open(orig_loc, mode='r') as rfile: + template = string.Template(rfile.read()) + + version = Version(autorelease.version.version).base_version + with open(target_loc, mode='w') as wfile: + wfile.write(template.substitute(VERSION=version)) def vendor_actions(base_path): resources = ['autorelease-default-env.sh', 'autorelease-prep.yml', From 558bd49b2aec715b8865320b96e268c3a1fa4b86 Mon Sep 17 00:00:00 2001 From: "David W.H. Swenson" Date: Thu, 13 May 2021 00:40:19 +0200 Subject: [PATCH 2/4] better workflow names --- autorelease/gh_actions_stages/autorelease-deploy.yml | 2 +- autorelease/gh_actions_stages/autorelease-gh-rel.yml | 4 +++- autorelease/gh_actions_stages/autorelease-prep.yml | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/autorelease/gh_actions_stages/autorelease-deploy.yml b/autorelease/gh_actions_stages/autorelease-deploy.yml index 08b643c..9a92321 100644 --- a/autorelease/gh_actions_stages/autorelease-deploy.yml +++ b/autorelease/gh_actions_stages/autorelease-deploy.yml @@ -1,6 +1,6 @@ # Vendored from Autorelease $VERSION # Update by updating Autorelease and running `autorelease vendor actions` -name: Autorelease +name: "Autorelease Deploy" on: release: types: [published] diff --git a/autorelease/gh_actions_stages/autorelease-gh-rel.yml b/autorelease/gh_actions_stages/autorelease-gh-rel.yml index 1809fee..ba8105b 100644 --- a/autorelease/gh_actions_stages/autorelease-gh-rel.yml +++ b/autorelease/gh_actions_stages/autorelease-gh-rel.yml @@ -1,9 +1,10 @@ # Vendored from Autorelease $VERSION # Update by updating Autorelease and running `autorelease vendor actions` -name: Autorelease +name: "Autorelease Release" on: push: branches: + # TODO: this should come from yaml conf - stable jobs: @@ -33,3 +34,4 @@ jobs: autorelease-release --project $$PROJECT --version $$VERSION --token $$AUTORELEASE_TOKEN env: AUTORELEASE_TOKEN: $${{ secrets.AUTORELEASE_TOKEN }} + name: "Cut release" diff --git a/autorelease/gh_actions_stages/autorelease-prep.yml b/autorelease/gh_actions_stages/autorelease-prep.yml index c3e8086..1966ed3 100644 --- a/autorelease/gh_actions_stages/autorelease-prep.yml +++ b/autorelease/gh_actions_stages/autorelease-prep.yml @@ -1,9 +1,10 @@ # Vendored from Autorelease $VERSION # Update by updating Autorelease and running `autorelease vendor actions` -name: "Autorelease" +name: "Autorelease testpypi" on: pull_request: branches: + # TODO: this should come from yaml conf - stable defaults: From a1ebe6a5c70c5aa8b849c9290a871327ff81a5a1 Mon Sep 17 00:00:00 2001 From: "David W.H. Swenson" Date: Thu, 13 May 2021 02:09:21 +0200 Subject: [PATCH 3/4] update vendored actions --- .github/workflows/autorelease-deploy.yml | 2 +- .github/workflows/autorelease-gh-rel.yml | 4 +++- .github/workflows/autorelease-prep.yml | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/autorelease-deploy.yml b/.github/workflows/autorelease-deploy.yml index f30139c..5b91173 100644 --- a/.github/workflows/autorelease-deploy.yml +++ b/.github/workflows/autorelease-deploy.yml @@ -1,6 +1,6 @@ # Vendored from Autorelease 0.3.1 # Update by updating Autorelease and running `autorelease vendor actions` -name: Autorelease +name: "Autorelease Deploy" on: release: types: [published] diff --git a/.github/workflows/autorelease-gh-rel.yml b/.github/workflows/autorelease-gh-rel.yml index 0d17f90..4d11807 100644 --- a/.github/workflows/autorelease-gh-rel.yml +++ b/.github/workflows/autorelease-gh-rel.yml @@ -1,9 +1,10 @@ # Vendored from Autorelease 0.3.1 # Update by updating Autorelease and running `autorelease vendor actions` -name: Autorelease +name: "Autorelease Release" on: push: branches: + # TODO: this should come from yaml conf - stable jobs: @@ -33,3 +34,4 @@ jobs: autorelease-release --project $PROJECT --version $VERSION --token $AUTORELEASE_TOKEN env: AUTORELEASE_TOKEN: ${{ secrets.AUTORELEASE_TOKEN }} + name: "Cut release" diff --git a/.github/workflows/autorelease-prep.yml b/.github/workflows/autorelease-prep.yml index 3fc009d..1f01841 100644 --- a/.github/workflows/autorelease-prep.yml +++ b/.github/workflows/autorelease-prep.yml @@ -1,9 +1,10 @@ # Vendored from Autorelease 0.3.1 # Update by updating Autorelease and running `autorelease vendor actions` -name: "Autorelease" +name: "Autorelease testpypi" on: pull_request: branches: + # TODO: this should come from yaml conf - stable defaults: From ca32d14b4debf1500bef5bb1bd8beec9825e7ca3 Mon Sep 17 00:00:00 2001 From: "David W.H. Swenson" Date: Thu, 13 May 2021 02:16:37 +0200 Subject: [PATCH 4/4] master => main in action --- .github/workflows/unit-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 36c8411..ca7bbb9 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -2,11 +2,11 @@ name: "Unit tests" on: pull_request: branches: - - master + - main - stable push: branches: - - master + - main tags: - "v*" schedule: