-
Notifications
You must be signed in to change notification settings - Fork 1
184 lines (167 loc) · 6.3 KB
/
Copy pathrelease-please.yml
File metadata and controls
184 lines (167 loc) · 6.3 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: Release Please
on:
workflow_dispatch:
inputs:
release_tag:
description: Existing release tag to build and publish assets for
required: false
type: string
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
permissions: {}
jobs:
release-please:
if: ${{ github.event.inputs.release_tag == '' }}
runs-on: ubuntu-latest
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
permissions:
contents: write
pull-requests: write
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- name: Release Please
id: release
uses: googleapis/release-please-action@v4.4.0
with:
config-file: .github/release-please/config.json
manifest-file: .github/release-please/manifest.json
- name: Sync GitHub release notes body
if: ${{ steps.release.outputs.release_created == 'true' && steps.release.outputs.tag_name != '' && steps.release.outputs.body != '' }}
uses: actions/github-script@v8
env:
RELEASE_TAG: ${{ steps.release.outputs.tag_name }}
RELEASE_BODY: ${{ steps.release.outputs.body }}
with:
script: |
const { owner, repo } = context.repo;
const release = await github.rest.repos.getReleaseByTag({
owner,
repo,
tag: process.env.RELEASE_TAG,
});
await github.rest.repos.updateRelease({
owner,
repo,
release_id: release.data.id,
body: process.env.RELEASE_BODY,
});
existing-release-target:
if: ${{ github.event.inputs.release_tag != '' }}
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.target.outputs.release_created }}
tag_name: ${{ steps.target.outputs.tag_name }}
steps:
- name: Use existing release tag
id: target
run: |
echo "release_created=true" >> "$GITHUB_OUTPUT"
echo "tag_name=${{ github.event.inputs.release_tag }}" >> "$GITHUB_OUTPUT"
release-binaries:
name: Build release binaries (${{ matrix.target }})
needs:
- release-please
- existing-release-target
if: ${{ always() && (needs.release-please.outputs.release_created == 'true' || needs.existing-release-target.outputs.release_created == 'true') && (needs.release-please.outputs.tag_name != '' || needs.existing-release-target.outputs.tag_name != '') }}
runs-on: ${{ matrix.runner }}
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
RELEASE_TAG: ${{ needs.release-please.outputs.tag_name || needs.existing-release-target.outputs.tag_name }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
binary_name: rustipo
- runner: macos-15-intel
target: x86_64-apple-darwin
binary_name: rustipo
- runner: macos-14
target: aarch64-apple-darwin
binary_name: rustipo
- runner: windows-latest
target: x86_64-pc-windows-msvc
binary_name: rustipo.exe
steps:
- name: Check out release tag
uses: actions/checkout@v6
with:
ref: ${{ env.RELEASE_TAG }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache Rust build outputs
uses: Swatinem/rust-cache@v2
with:
key: release-${{ matrix.target }}
- name: Build release binary
run: cargo build --release --locked --target ${{ matrix.target }}
- name: Package release archive (Unix)
if: runner.os != 'Windows'
shell: bash
env:
TARGET: ${{ matrix.target }}
BINARY_NAME: ${{ matrix.binary_name }}
run: |
set -euo pipefail
archive_stem="${RELEASE_TAG}-${TARGET}"
stage_dir="$archive_stem"
mkdir -p "$stage_dir"
cp "target/${TARGET}/release/${BINARY_NAME}" "$stage_dir/"
cp README.md LICENSE.md "$stage_dir/"
tar -czf "${archive_stem}.tar.gz" "$stage_dir"
- name: Package release archive (Windows)
if: runner.os == 'Windows'
shell: pwsh
env:
TARGET: ${{ matrix.target }}
BINARY_NAME: ${{ matrix.binary_name }}
run: |
$archiveStem = "$env:RELEASE_TAG-$env:TARGET"
New-Item -ItemType Directory -Path $archiveStem | Out-Null
Copy-Item "target/$env:TARGET/release/$env:BINARY_NAME" $archiveStem
Copy-Item README.md $archiveStem
Copy-Item LICENSE.md $archiveStem
Compress-Archive -Path "$archiveStem/*" -DestinationPath "$archiveStem.zip"
- name: Upload release archive artifact
uses: actions/upload-artifact@v7
with:
name: release-binary-${{ matrix.target }}
path: ${{ github.workspace }}/${{ env.RELEASE_TAG }}-${{ matrix.target }}.*
if-no-files-found: error
publish-release-assets:
name: Publish release assets
runs-on: ubuntu-latest
needs:
- release-please
- existing-release-target
- release-binaries
if: ${{ always() && (needs.release-please.outputs.release_created == 'true' || needs.existing-release-target.outputs.release_created == 'true') && (needs.release-please.outputs.tag_name != '' || needs.existing-release-target.outputs.tag_name != '') }}
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
RELEASE_TAG: ${{ needs.release-please.outputs.tag_name || needs.existing-release-target.outputs.tag_name }}
permissions:
contents: write
steps:
- name: Download packaged release archives
uses: actions/download-artifact@v8
with:
pattern: release-binary-*
path: release-assets
merge-multiple: true
- name: Generate release checksums
working-directory: release-assets
run: sha256sum * > "${RELEASE_TAG}-sha256sums.txt"
- name: Upload release assets
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.RELEASE_TAG }}
files: release-assets/*
fail_on_unmatched_files: true