Skip to content

Commit

Permalink
ci(release): move release workflow to trigger on release publish
Browse files Browse the repository at this point in the history
  • Loading branch information
EdenEast committed Nov 1, 2023
1 parent 77de058 commit 9610ada
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 31 deletions.
22 changes: 21 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: check
permissions:
contents: read
contents: write
pull-requests: write
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
env:
CARGO_REGISTRY_CRATES_IO_PROTOCOL: true
concurrency: # Spend CI time only on latest ref: https://docs.github.com/en/actions/using-jobs/using-concurrency
Expand Down Expand Up @@ -109,3 +111,21 @@ jobs:
- name: Build | Build [Cross]
if: matrix.os == 'ubuntu-latest'
run: cross build --locked --target ${{ matrix.target }}

release_please:
name: Release Please
runs-on: ubuntu-latest
if: github.repository == 'edeneast/tuxmux' && github.event_name == 'push' && github.ref_name == 'main'
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: rust
bump-minor-pre-major: true
bump-patch-for-minor-pre-major: true
package-name: tuxmux
draft: true
35 changes: 5 additions & 30 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,15 @@ permissions:
contents: write
pull-requests: write
on:
workflow_dispatch:
push:
branches:
- main
release:
types: [ published ]

env:
CARGO_INCREMENTAL: 0

jobs:
release_please:
name: Release Please
runs-on: ubuntu-latest
if: github.repository == 'edeneast/tuxmux'
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: rust
bump-minor-pre-major: true
bump-patch-for-minor-pre-major: true
package-name: tuxmux
draft: true

# ---------------------------------------------------------------------------

github_build:
name: Build release binaries
needs: [ release_please ]
if: ${{ needs.release-please.outputs.release_created == 'true' }}
strategy:
matrix:
Expand Down Expand Up @@ -95,8 +72,7 @@ jobs:

upload_artifacts:
name: Add build artifacts to release
needs: [ release_please, github_build ]
if: ${{ needs.release-please.outputs.release_created == 'true' }}
needs: github_build
runs-on: ubuntu-latest
steps:
- name: Setup | Artifacts
Expand All @@ -106,7 +82,7 @@ jobs:
run: for file in tuxmux-*/tuxmux-*; do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done

- name: Build | Publish release
run: gh release edit ${{ needs.release_please.outputs.tag_name }} --draft=true --repo=edeneast/tuxmux
run: gh release edit ${{ github.event.release.tag_name }} --repo=edeneast/tuxmux
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -120,8 +96,7 @@ jobs:

publish_crate:
name: Publish cargo package
needs: [ release_please, github_build ]
if: ${{ needs.release-please.outputs.release_created == 'true' }}
needs: github_build
runs-on: ubuntu-latest
steps:
- name: Setup | Checkout
Expand Down

0 comments on commit 9610ada

Please sign in to comment.