Skip to content

Commit 9794be7

Browse files
committed
ci: Switch to release-pr for releases
1 parent ae99fd2 commit 9794be7

File tree

1 file changed

+31
-179
lines changed

1 file changed

+31
-179
lines changed

.github/workflows/release.yml

Lines changed: 31 additions & 179 deletions
Original file line numberDiff line numberDiff line change
@@ -1,187 +1,39 @@
1-
# Copyright 2022-2023, axodotdev
2-
# SPDX-License-Identifier: MIT or Apache-2.0
3-
#
4-
# CI that:
5-
#
6-
# * checks for a Git Tag that looks like a release
7-
# * builds artifacts with cargo-dist (archives, installers, hashes)
8-
# * uploads those artifacts to temporary workflow zip
9-
# * on success, uploads the artifacts to a Github Release™
10-
#
11-
# Note that the Github Release™ will be created with a generated
12-
# title/body based on your changelogs.
13-
name: Release
14-
15-
permissions:
16-
contents: write
17-
18-
# This task will run whenever you push a git tag that looks like a version
19-
# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc.
20-
# Various formats will be parsed into a VERSION and an optional PACKAGE_NAME, where
21-
# PACKAGE_NAME must be the name of a Cargo package in your workspace, and VERSION
22-
# must be a Cargo-style SemVer Version (must have at least major.minor.patch).
23-
#
24-
# If PACKAGE_NAME is specified, then the release will be for that
25-
# package (erroring out if it doesn't have the given version or isn't cargo-dist-able).
26-
#
27-
# If PACKAGE_NAME isn't specified, then the release will be for all
28-
# (cargo-dist-able) packages in the workspace with that version (this mode is
29-
# intended for workspaces with only one dist-able package, or with all dist-able
30-
# packages versioned/released in lockstep).
31-
#
32-
# If you push multiple tags at once, separate instances of this workflow will
33-
# spin up, creating an independent Github Release™ for each one. However Github
34-
# will hard limit this to 3 tags per commit, as it will assume more tags is a
35-
# mistake.
36-
#
37-
# If there's a prerelease-style suffix to the version, then the Github Release™
38-
# will be marked as a prerelease.
1+
name: Open a release PR
392
on:
40-
push:
41-
tags:
42-
- "**[0-9]+.[0-9]+.[0-9]+*"
43-
pull_request:
3+
workflow_dispatch:
4+
inputs:
5+
crate:
6+
description: Crate to release
7+
required: true
8+
type: choice
9+
options:
10+
- widget
11+
- gadget
12+
- budget
13+
- fidget
14+
- nugget
15+
version:
16+
description: Version to release
17+
required: true
18+
type: string
4419

4520
jobs:
46-
# Run 'cargo dist plan' to determine what tasks we need to do
47-
plan:
21+
make-release-pr:
22+
permissions:
23+
id-token: write # Enable OIDC
24+
pull-requests: write
25+
contents: write
4826
runs-on: ubuntu-latest
49-
outputs:
50-
val: ${{ steps.plan.outputs.manifest }}
51-
tag: ${{ !github.event.pull_request && github.ref_name || '' }}
52-
tag-flag: ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }}
53-
publishing: ${{ !github.event.pull_request }}
54-
env:
55-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5627
steps:
57-
- uses: actions/checkout@v4
58-
with:
59-
submodules: recursive
60-
- name: Install cargo-dist
61-
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.4.2/cargo-dist-installer.sh | sh"
62-
- id: plan
63-
run: |
64-
cargo dist plan ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }} --output-format=json > dist-manifest.json
65-
echo "cargo dist plan ran successfully"
66-
cat dist-manifest.json
67-
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
68-
- name: "Upload dist-manifest.json"
69-
uses: actions/upload-artifact@v4
28+
- uses: actions/checkout@v3
29+
- uses: chainguard-dev/actions/setup-gitsign@main
30+
- name: Install cargo-release
31+
uses: taiki-e/install-action@v1
7032
with:
71-
name: artifacts-${{ matrix.runs-on }}
72-
path: dist-manifest.json
33+
tool: cargo-release
7334

74-
# Build and packages all the platform-specific things
75-
upload-local-artifacts:
76-
# Let the initial task tell us to not run (currently very blunt)
77-
needs: plan
78-
if: ${{ fromJson(needs.plan.outputs.val).releases != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }}
79-
strategy:
80-
fail-fast: false
81-
# Target platforms/runners are computed by cargo-dist in create-release.
82-
# Each member of the matrix has the following arguments:
83-
#
84-
# - runner: the github runner
85-
# - dist-args: cli flags to pass to cargo dist
86-
# - install-dist: expression to run to install cargo-dist on the runner
87-
#
88-
# Typically there will be:
89-
# - 1 "global" task that builds universal installers
90-
# - N "local" tasks that build each platform's binaries and platform-specific installers
91-
matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
92-
runs-on: ${{ matrix.runner }}
93-
env:
94-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95-
BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
96-
steps:
97-
- name: Install dependencies (Ubuntu)
98-
run: |
99-
sudo apt-get update -qqq
100-
sudo apt-get install -yqq python3-dev
101-
if: ${{ runner.os == 'Linux' }}
102-
- name: Install dependencies (MacOS)
103-
run: |
104-
brew install [email protected]
105-
if: ${{ runner.os == 'macOS' }}
106-
- name: Install Protoc
107-
uses: arduino/setup-protoc@v2
108-
with:
109-
version: "23.2" # Fixed since we mount the path below
110-
repo-token: ${{ secrets.GITHUB_TOKEN }}
111-
- uses: actions/checkout@v4
112-
with:
113-
submodules: recursive
114-
- uses: swatinem/rust-cache@v2
115-
with:
116-
workspaces: "libs"
117-
- name: Install cargo-dist
118-
run: ${{ matrix.install_dist }}
119-
- name: Install dependencies
120-
run: |
121-
${{ matrix.packages_install }}
122-
- name: Build artifacts
123-
run: |
124-
echo ${{ runner.os }}
125-
# Actually do builds and make zips and whatnot
126-
cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
127-
echo "cargo dist ran successfully"
128-
cat dist-manifest.json
129-
- id: cargo-dist
130-
name: Post-build
131-
# We force bash here just because github makes it really hard to get values up
132-
# to "real" actions without writing to env-vars, and writing to env-vars has
133-
# inconsistent syntax between shell and powershell.
134-
shell: bash
135-
run: |
136-
# Parse out what we just built and upload it to the Github Release™
137-
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
138-
jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT"
139-
echo "EOF" >> "$GITHUB_OUTPUT"
140-
141-
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
142-
- name: "Upload artifacts"
143-
uses: actions/upload-artifact@v4
144-
with:
145-
name: artifacts-${{ matrix.runs-on }}
146-
path: |
147-
${{ steps.cargo-dist.outputs.paths }}
148-
${{ env.BUILD_MANIFEST_NAME }}
149-
150-
should-publish:
151-
needs:
152-
- plan
153-
- upload-local-artifacts
154-
if: ${{ needs.plan.outputs.publishing == 'true' }}
155-
runs-on: ubuntu-latest
156-
steps:
157-
- name: print tag
158-
run: echo "ok we're publishing!"
159-
160-
# Create a Github Release with all the results once everything is done
161-
publish-release:
162-
needs: [plan, should-publish]
163-
runs-on: ubuntu-latest
164-
env:
165-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
166-
steps:
167-
- uses: actions/checkout@v4
168-
with:
169-
submodules: recursive
170-
- name: "Download artifacts"
171-
uses: actions/download-artifact@v4
172-
with:
173-
path: artifacts
174-
pattern: artifacts-*
175-
merge-multiple: true
176-
- name: Cleanup
177-
run: |
178-
# Remove the granular manifests
179-
rm artifacts/*-dist-manifest.json
180-
- name: Create Release
181-
uses: ncipollo/release-action@v1
35+
- uses: cargo-bins/release-pr@v2
18236
with:
183-
tag: ${{ needs.plan.outputs.tag }}
184-
name: ${{ fromJson(needs.plan.outputs.val).announcement_title }}
185-
body: ${{ fromJson(needs.plan.outputs.val).announcement_github_body }}
186-
prerelease: ${{ fromJson(needs.plan.outputs.val).announcement_is_prerelease }}
187-
artifacts: "artifacts/*"
37+
github-token: ${{ secrets.GITHUB_TOKEN }}
38+
version: ${{ inputs.version }}
39+
crate-name: ${{ inputs.crate }}

0 commit comments

Comments
 (0)