Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add release_please action #9

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 28 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,30 @@ on:
pull_request:

jobs:
# Create release PR
release_please:
name: Create release PR
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
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

# Run 'cargo dist plan' to determine what tasks we need to do
plan:
needs: release_please
runs-on: ubuntu-latest
outputs:
val: ${{ steps.plan.outputs.manifest }}
tag: ${{ !github.event.pull_request && github.ref_name || '' }}
tag-flag: ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }}
publishing: ${{ !github.event.pull_request }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
Expand All @@ -74,8 +90,8 @@ jobs:
# Build and packages all the platform-specific things
upload-local-artifacts:
# Let the initial task tell us to not run (currently very blunt)
needs: plan
if: ${{ fromJson(needs.plan.outputs.val).releases != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }}
needs: [release_please, plan]
if: ${{ fromJson(needs.plan.outputs.val).releases != null && (needs.release_please.outputs.release_created == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }}
strategy:
fail-fast: false
# Target platforms/runners are computed by cargo-dist in create-release.
Expand Down Expand Up @@ -131,7 +147,7 @@ jobs:

# Build and package all the platform-agnostic(ish) things
upload-global-artifacts:
needs: [plan, upload-local-artifacts]
needs: [release_please, plan, upload-local-artifacts]
runs-on: "ubuntu-20.04"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -163,26 +179,15 @@ jobs:
name: artifacts
path: ${{ steps.cargo-dist.outputs.paths }}

should-publish:
needs:
- plan
- upload-local-artifacts
- upload-global-artifacts
if: ${{ needs.plan.outputs.publishing == 'true' }}
runs-on: ubuntu-latest
steps:
- name: print tag
run: echo "ok we're publishing!"

publish-homebrew-formula:
needs: [plan, should-publish]
needs: [release_please, plan]
runs-on: "ubuntu-20.04"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PLAN: ${{ needs.plan.outputs.val }}
GITHUB_USER: "axo bot"
GITHUB_EMAIL: "[email protected]"
if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }}
if: ${{ needs.release_please.outputs.release_created == 'true' }}
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -210,7 +215,8 @@ jobs:

# Create a Github Release with all the results once everything is done
publish-release:
needs: [plan, should-publish]
needs: [release_please, plan]
if: ${{ needs.release_please.outputs.release_created == 'true' }}
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -228,10 +234,7 @@ jobs:
# Remove the granular manifests
rm artifacts/*-dist-manifest.json
- name: Create Release
uses: ncipollo/release-action@v1
uses: softprops/action-gh-release@v1
with:
tag: ${{ needs.plan.outputs.tag }}
name: ${{ fromJson(needs.plan.outputs.val).announcement_title }}
body: ${{ fromJson(needs.plan.outputs.val).announcement_github_body }}
prerelease: ${{ fromJson(needs.plan.outputs.val).announcement_is_prerelease }}
artifacts: "artifacts/*"
files: artifacts/*
tag_name: ${{ needs.release_please.outputs.tag_name }}
Loading