-
-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (98 loc) · 2.61 KB
/
create-release.yml
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
permissions:
contents: read
on:
workflow_call:
inputs:
rust:
required: false
type: string
default: stable
target:
required: false
type: string
args:
required: false
type: string
crates:
required: false
type: string
default: '.'
changelog:
required: false
type: string
default: CHANGELOG.md
title:
required: false
type: string
default: $version
branch:
required: false
type: string
default: main
secrets:
CARGO_REGISTRY_TOKEN:
required: true
env:
CARGO_INCREMENTAL: 0
CARGO_NET_GIT_FETCH_WITH_CLI: true
CARGO_NET_RETRY: 10
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
RUSTFLAGS: -D warnings
RUSTDOCFLAGS: -D warnings
RUSTUP_MAX_RETRIES: 10
defaults:
run:
shell: bash --noprofile --norc -CeEuo pipefail {0}
jobs:
create-release:
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
contents: write
steps:
- uses: taiki-e/checkout-action@v1
- uses: taiki-e/github-actions/install-rust@main
with:
toolchain: ${{ inputs.rust }}
target: ${{ inputs.target }}
- run: |
printf '%s\n' "TARGET=--target=${{ inputs.target }}" >>"${GITHUB_ENV}"
if: inputs.target != ''
- run: |
crates=()
while read -rd,; do
crates+=("${REPLY}")
done <<<"${{ inputs.crates }},"
for i in "${!crates[@]}"; do
(
set -x
cd -- "${crates[${i}]}"
cargo build ${TARGET:-} ${{ inputs.args }}
)
done
- uses: taiki-e/create-gh-release-action@v1
with:
changelog: ${{ inputs.changelog }}
title: ${{ inputs.title }}
branch: ${{ inputs.branch }}
token: ${{ secrets.GITHUB_TOKEN }}
- run: |
crates=()
while read -rd,; do
crates+=("${REPLY}")
done <<<"${{ inputs.crates }},"
for i in "${!crates[@]}"; do
(
set -x
cd -- "${crates[${i}]}"
# TODO: retry on failure
# TODO: handle already published case: https://github.com/rust-lang/cargo/blob/0.80.0/publish.py#L35
cargo publish ${TARGET:-} ${{ inputs.args }}
)
if [[ $((i + 1)) != "${#crates[@]}" ]]; then
sleep 45 # cargo's waiting is sometimes not enough
fi
done
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}