Skip to content

Commit

Permalink
split tag and publish
Browse files Browse the repository at this point in the history
  • Loading branch information
getzze committed Nov 12, 2024
1 parent aa51d89 commit 7b4076b
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 33 deletions.
33 changes: 0 additions & 33 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@ on:
- main
tags:
- '*'
pull_request:
types:
- closed
release:
types:
- published
workflow_dispatch:

permissions:
contents: read
Expand All @@ -34,35 +30,6 @@ jobs:

- uses: hynek/build-and-inspect-python-package@v2

tag:
name: Tag a new release
# tag a release after a release PR was accepted
if: |
github.event_name == 'pull_request'
&& github.event.action == 'closed'
&& github.event.pull_request.merged == true
&& startsWith(github.head_ref, 'release-')
needs: [build-package]
env:
GITHUB_HEAD_REF: ${{ github.head_ref }}
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Tag the commit
run: |
RELEASE_VERSION=${GITHUB_HEAD_REF#release-}
echo Release version: $RELEASE_VERSION
git config user.name 'subliminal bot'
git config user.email [email protected]
git tag --annotate --message="Release version $RELEASE_VERSION" $RELEASE_VERSION ${{ github.sha }}
git push origin $RELEASE_VERSION
github-release:
name: Make a GitHub Release
needs: [build-package]
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/tag-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Tag release

on:
pull_request:
types:
- closed
workflow_dispatch:
inputs:
version:
description: 'Release tag version.'
type: string
default: NONE
required: true

permissions:
contents: read
id-token: write

env:
FORCE_COLOR: "1"

# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
jobs:
# Always build & lint package.
build-package:
name: Build & verify package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: hynek/build-and-inspect-python-package@v2

tag:
name: Tag a new release
# tag a release after a release PR was accepted
if: |
github.event_name == 'pull_request'
&& github.event.action == 'closed'
&& github.event.pull_request.merged == true
&& startsWith(github.head_ref, 'release-')
needs: [build-package]
env:
GITHUB_HEAD_REF: ${{ github.head_ref }}
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Tag the commit
run: |
RELEASE_VERSION=${GITHUB_HEAD_REF#release-}
echo Release version: $RELEASE_VERSION
git config user.name 'subliminal bot'
git config user.email [email protected]
git tag --annotate --message="Release version $RELEASE_VERSION" $RELEASE_VERSION ${{ github.sha }}
git push origin $RELEASE_VERSION

0 comments on commit 7b4076b

Please sign in to comment.