From a666e67e93d82dcfe3bea915ab406642d6639a29 Mon Sep 17 00:00:00 2001 From: fordnox Date: Thu, 7 Dec 2023 12:56:49 +0200 Subject: [PATCH] ci --- .github/workflows/bump.yaml | 60 ++++++++++++++++++++++++++++ .github/workflows/python-package.yml | 17 -------- 2 files changed, 60 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/bump.yaml diff --git a/.github/workflows/bump.yaml b/.github/workflows/bump.yaml new file mode 100644 index 0000000..83da53f --- /dev/null +++ b/.github/workflows/bump.yaml @@ -0,0 +1,60 @@ +name: Bump version + +on: + workflow_dispatch: + inputs: + bump_rule: + type: choice + description: How to bump the project's version (see https://python-poetry.org/docs/cli/#version) + options: + - patch + - minor + - major + - prepatch + - preminor + - premajor + - prerelease + required: true + +jobs: + bump_version: + name: "Bump version and create changelog" + if: "!startsWith(github.event.head_commit.message, 'bump:')" + runs-on: ubuntu-latest + env: + CI_COMMIT_EMAIL: "ci-runner@openscm-units.invalid" + steps: + - name: Check out repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}" + + # towncrier imports the package as part of building so we have to + # install the pacakage (to keep things slim, we only install the main + # dependencies, which also means that we get a test that we can import + # the package with only the compulsory dependencies installed for free) + - uses: ./.github/actions/setup + with: + python-version: "3.11" + venv-id: "bump" + poetry-dependency-install-flags: "--only main" + + - name: Install towncrier + run: | + poetry run pip install towncrier + + - name: Create bump and changelog + + run: | + BASE_VERSION=`poetry version -s` + NEW_VERSION=`poetry version -s ${{ github.event.inputs.bump_rule }}` + poetry run towncrier build --yes --version v$NEW_VERSION + + git config --global user.name "$GITHUB_ACTOR" + git config --global user.email "$CI_COMMIT_EMAIL" + + git commit -a -m "bump: version $BASE_VERSION -> $NEW_VERSION" + git tag v$NEW_VERSION + git push && git push --tags + echo "Bumped to version $NEW_VERSION" diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 0d95925..c336a9d 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -33,20 +33,3 @@ jobs: - name: Test with pytest run: | poetry run pytest -s - - tag-release: - needs: build -# if: ${{ github.repository == 'fordnox/wordplex' }} - runs-on: ubuntu-20.04 - - permissions: - contents: write - - steps: - - uses: actions/checkout@v3 - - run: /usr/bin/git config --global user.email actions@github.com - - run: /usr/bin/git config --global user.name 'GitHub Actions Release Tagger' - - run: | - git commit -m "Release $(shell poetry version -s)" - git tag v$(shell poetry version -s) - git push origin --tags