Repository navigation
78 lines (71 loc) · 2.92 KB
/
Copy pathrelease.yml
File metadata and controls
78 lines (71 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Release
on:
push:
branches: [main]
workflow_dispatch:
inputs:
publish_only:
description: "Skip release-please, run publish directly (for retrying failed publishes)"
type: boolean
default: false
permissions:
contents: write
pull-requests: write
env:
CARGO_TERM_COLOR: always
jobs:
release-please:
name: Release Please
runs-on: ubuntu-latest
outputs:
releases_created: ${{ steps.release.outputs.releases_created }}
paths_released: ${{ steps.release.outputs.paths_released }}
steps:
- uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 #v5.0.0
id: release
with:
config-file: release-please-config.json
manifest-file: .release-please-manifest.json
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
needs: release-please
if: |
needs.release-please.outputs.releases_created == 'true' ||
inputs.publish_only == true
environment: crates-io
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
- uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 #v1.16.1
# cli-engine depends on cli-engine-macros, so the macro crate must be
# live on crates.io first. Not every release bumps its version, so
# "already published" is expected and not a failure in general — BUT
# only when release-please didn't actually cut a release for
# cli-engine-macros this round. If it did (paths_released includes it)
# and crates.io still reports the version as already published, that
# means the version bump didn't happen despite real changes, and
# publishing cli-engine anyway would ship it against a stale
# cli-engine-macros that's missing the intended update — fail loudly
# instead of silently continuing.
- name: Publish cli-engine-macros
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
PATHS_RELEASED: ${{ needs.release-please.outputs.paths_released }}
run: |
cd cli-engine-macros
if ! output=$(cargo publish 2>&1); then
echo "$output"
if echo "$output" | grep -qi "already exists\|already uploaded"; then
if echo "$PATHS_RELEASED" | jq -e 'index("cli-engine-macros")' >/dev/null 2>&1; then
echo "::error::release-please released cli-engine-macros this round, but crates.io already has this version — its Cargo.toml version was likely not bumped despite real changes"
exit 1
fi
echo "cli-engine-macros wasn't part of this release; already published at this version, continuing"
else
exit 1
fi
fi
- name: Publish cli-engine
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
run: cargo publish -p cli-engine