Skip to content

Commit 6cecfe0

Browse files
committed
Update release.yml for tag-based releases and add custom cargo publish workflow
1 parent 0ebfd5b commit 6cecfe0

4 files changed

Lines changed: 57 additions & 15 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
tag:
5+
description: 'Tag to publish'
6+
required: true
7+
type: string
8+
9+
jobs:
10+
publish:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
id-token: write
14+
steps:
15+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
16+
with:
17+
ref: ${{ inputs.tag }}
18+
- name: Get crates.io Token
19+
uses: rust-lang/crates-io-auth-action@bbd81622f20ce9e2dd9622e3218b975523e45bbe
20+
id: auth
21+
- name: Publish to crates.io
22+
run: cargo publish
23+
env:
24+
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}

.github/workflows/release.yml

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,31 +39,27 @@ permissions:
3939
# If there's a prerelease-style suffix to the version, then the release(s)
4040
# will be marked as a prerelease.
4141
on:
42-
workflow_dispatch:
43-
44-
workflow_call:
45-
inputs:
46-
tag:
47-
description: 'Tag to publish'
48-
required: true
49-
type: string
42+
pull_request:
43+
push:
44+
tags:
45+
- '**[0-9]+.[0-9]+.[0-9]+*'
5046

5147
jobs:
5248
# Run 'dist plan' (or host) to determine what tasks we need to do
5349
plan:
5450
runs-on: "ubuntu-22.04"
5551
outputs:
5652
val: ${{ steps.plan.outputs.manifest }}
57-
tag: ${{ inputs.tag }}
58-
tag-flag: ${{ format('--tag={0}', inputs.tag) }}
59-
publishing: true
53+
tag: ${{ !github.event.pull_request && github.ref_name || '' }}
54+
tag-flag: ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }}
55+
publishing: ${{ !github.event.pull_request }}
6056
env:
6157
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6258
steps:
6359
- uses: actions/checkout@v6
6460
with:
6561
persist-credentials: false
66-
ref: ${{ inputs.tag }}
62+
submodules: recursive
6763
- name: Install dist
6864
# we specify bash to get pipefail; it guards against the `curl` command
6965
# failing. otherwise `sh` won't catch that `curl` returned non-0
@@ -81,7 +77,7 @@ jobs:
8177
# but also really annoying to build CI around when it needs secrets to work right.)
8278
- id: plan
8379
run: |
84-
dist ${{ format('host --steps=create --tag={0}', inputs.tag) || 'plan' }} --output-format=json > plan-dist-manifest.json
80+
dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
8581
echo "dist ran successfully"
8682
cat plan-dist-manifest.json
8783
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
@@ -282,14 +278,30 @@ jobs:
282278
283279
gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
284280
281+
custom-publish_to_cargo:
282+
needs:
283+
- plan
284+
- host
285+
if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }}
286+
uses: ./.github/workflows/publish_to_cargo.yml
287+
with:
288+
plan: ${{ needs.plan.outputs.val }}
289+
tag: ${{ needs.plan.outputs.tag }}
290+
secrets: inherit
291+
# publish jobs get escalated permissions
292+
permissions:
293+
"id-token": "write"
294+
"packages": "write"
295+
285296
announce:
286297
needs:
287298
- plan
288299
- host
300+
- custom-publish_to_cargo
289301
# use "always() && ..." to allow us to wait for all publish jobs while
290302
# still allowing individual publish jobs to skip themselves (for prereleases).
291303
# "host" however must run to completion, no skipping allowed!
292-
if: ${{ always() && needs.host.result == 'success' }}
304+
if: ${{ always() && needs.host.result == 'success' && (needs.custom-publish_to_cargo.result == 'skipped' || needs.custom-publish_to_cargo.result == 'success') }}
293305
runs-on: "ubuntu-22.04"
294306
env:
295307
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ codegen-units = 1
2929
# Abort on panic (removes panic unwinding information).
3030
panic = "abort"
3131

32+
# The profile that 'dist' will build with
33+
[profile.dist]
34+
inherits = "release"
35+
lto = "thin"
36+
3237
[lib]
3338
name = "aws_cli"
3439
path = "src/lib.rs"

dist-workspace.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ ci = "github"
1010
# The installers to generate for each app
1111
installers = []
1212
# Target platforms to build apps for (Rust target-triple syntax)
13-
targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "aarch64-pc-windows-msvc", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"]
13+
targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "aarch64-pc-windows-msvc", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"]
14+
publish-jobs = ["./publish_to_cargo"]

0 commit comments

Comments
 (0)