Skip to content

Commit

Permalink
Enhance GitHub actions workflows
Browse files Browse the repository at this point in the history
- Improve GitHub Actions workflows for manual and automated releases
- Define permissions and job dependencies for more organized release process
  • Loading branch information
johnnyhuy committed Apr 21, 2024
1 parent b969126 commit 65180a1
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
build:
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/pull-request-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Pull Request Release

on:
pull_request:
types: [opened, reopened, synchronize]
pull_request_target:
types: [opened, reopened, synchronize]

permissions:
contents: read

jobs:
pull-request-release:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45 changes: 38 additions & 7 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
permissions: write-all

jobs:
release:
draft-release:
runs-on: ubuntu-latest

outputs:
Expand All @@ -20,25 +20,56 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v4
- uses: release-drafter/release-drafter@v5
id: drafter
with:
publish: false

publish:
publish-package:
runs-on: ubuntu-latest
needs: release
needs: draft-release

strategy:
matrix:
arch: [linux/amd64, linux/arm64]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
VERSION: ${{ needs.draft-release.outputs.tag_name }}

steps:
- uses: actions/checkout@v4
- uses: asdf-vm/actions/install@v3
- run: make publish
- run: make publish-package

publish-image:
runs-on: ubuntu-latest
needs: draft-release

strategy:
matrix:
arch: [linux/amd64, linux/arm64]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ needs.draft-release.outputs.tag_name }}

steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- run: make publish-image
env:
VERSION: ${{ needs.release.outputs.tag_name }}
DOCKER_DEFAULT_PLATFORM: ${{ matrix.arch }}

publish-release:
runs-on: ubuntu-latest
needs:
- publish-package
- publish-image

steps:
- uses: actions/checkout@v4
- uses: release-drafter/release-drafter@v5
with:
publish: true

0 comments on commit 65180a1

Please sign in to comment.