Skip to content

feat: update workflow #44

feat: update workflow

feat: update workflow #44

Workflow file for this run

name: tag and release new version
on:
pull_request_target:
types:
- closed
jobs:
tag:
name: create git tag
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == github.event.repository.default_branch
runs-on: ubuntu-latest
outputs:
version: ${{ steps.bump.outputs.version }}
changes: ${{ steps.details.outputs.changes }}
is_new_version: ${{ steps.details.outputs.is_new_version }}
steps:
- id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.PUBLIC_RELEASE_MANAGER_ID }}
private-key: ${{ secrets.PUBLIC_RELEASE_MANAGER_SECRET }}
- uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
ref: ${{ github.event.repository.default_branch }}
fetch-depth: 999
fetch-tags: true
- id: bump
uses: commitizen-tools/commitizen-action@master
with:
changelog_increment_filename: .changes.md
git_redirect_stderr: true
commit: true
push: false
no_raise: 21
- id: details
shell: bash
run: |
{
echo 'changes<<EOF'
cat .changes.md
echo EOF
} >> "$GITHUB_OUTPUT"
if [ "$REVISION" != "$PREVIOUS_REVISION" ]; then
echo "is_new_version=1" >> "$GITHUB_OUTPUT"
# pushing seperately to use correct auth set up during actions/checkout
git push --atomic --tags origin HEAD:${GITHUB_REF_NAME}
fi
release:
name: create new release
needs:
- tag
if: ${{ needs.tag.outputs.is_new_version }}
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
env:
GIT_TAG: v${{ needs.tag.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ env.GIT_TAG }}
- name: Install poetry
run: pipx install poetry
- uses: actions/github-script@v7
env:
CHANGES: ${{ needs.tag.outputs.changes }}
with:
script: |
const { CHANGES, GIT_TAG } = process.env
github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: GIT_TAG,
body: CHANGES,
})
- name: Build package
run: poetry build
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
record_release_pact:
name: Record release in pactflow
needs:
- tag
- release
runs-on: ubuntu-latest
steps:
- id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.PUBLIC_RELEASE_MANAGER_ID }}
private-key: ${{ secrets.PUBLIC_RELEASE_MANAGER_SECRET }}
- uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
ref: ${{ github.event.repository.default_branch }}
# `fetch-depth` > 0 is required to have `ref` have an effect
fetch-depth: 999
fetch-tags: true
- name: Mark release in Pactflow 🚀
env:
ENVIRONMENT: production
GH_TOKEN: ${{ github.token }}
GIT_BRANCH: ${{ github.event.repository.default_branch }}
PACT_BROKER_BASE_URL: ${{ secrets.PACT_BROKER_BASE_URL }}
PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}
VERSION: ${{ needs.tag.outputs.version }}
run: |
make -f pact.mk set_branch_and_tag_pact
make -f pact.mk record_release