Repository navigation
117 lines (109 loc) · 4.57 KB
/
Copy pathrelease.yml
File metadata and controls
117 lines (109 loc) · 4.57 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
name: Release
on:
push:
branches: [master]
workflow_dispatch:
permissions:
contents: write
pull-requests: write
statuses: write
# Preparation pushes with GITHUB_TOKEN do not trigger PR workflows. Serialize the
# bot's branch updates and explicitly validate the prepared commit below.
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
release-please:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
pr_number: ${{ steps.release.outputs.pr && fromJSON(steps.release.outputs.pr).number || '' }}
prepared_sha: ${{ steps.prepare.outputs.sha }}
steps:
- uses: googleapis/release-please-action@v4.4.1
id: release
with:
config-file: release-please-config.json
manifest-file: .release-please-manifest.json
- uses: actions/checkout@v5
if: steps.release.outputs.pr != ''
with:
ref: ${{ fromJSON(steps.release.outputs.pr).headBranchName }}
- uses: dtolnay/rust-toolchain@stable
if: steps.release.outputs.pr != ''
with:
toolchain: "1.98.0"
- uses: Swatinem/rust-cache@v2
if: steps.release.outputs.pr != ''
- name: Install notice generator
if: steps.release.outputs.pr != ''
uses: taiki-e/install-action@v2
with:
tool: cargo-about@0.9.2
- name: Prepare release notices
if: steps.release.outputs.pr != ''
id: prepare
run: scripts/prepare-release-pr.sh
- name: Mark release validation pending
if: steps.prepare.outputs.sha != ''
uses: actions/github-script@v7
env:
PREPARED_SHA: ${{ steps.prepare.outputs.sha }}
with:
script: |
for (const name of ['Release validation', 'Conventional Commits']) {
await github.rest.repos.createCommitStatus({
...context.repo, sha: process.env.PREPARED_SHA,
context: name, state: 'pending',
description: 'Checking the prepared release commit',
target_url: `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
});
}
release-ci:
needs: release-please
if: needs.release-please.outputs.prepared_sha != ''
uses: ./.github/workflows/ci.yml
with:
ref: ${{ needs.release-please.outputs.prepared_sha }}
pr_number: ${{ fromJSON(needs.release-please.outputs.pr_number || '0') }}
release-package-validation:
needs: release-please
if: needs.release-please.outputs.prepared_sha != ''
uses: ./.github/workflows/package.yml
with:
ref: ${{ needs.release-please.outputs.prepared_sha }}
release-validation:
needs: [release-please, release-ci, release-package-validation]
if: always() && needs.release-please.outputs.prepared_sha != ''
runs-on: ubuntu-latest
steps:
- name: Report release validation
uses: actions/github-script@v7
env:
PREPARED_SHA: ${{ needs.release-please.outputs.prepared_sha }}
CI_RESULT: ${{ needs.release-ci.result }}
PACKAGE_RESULT: ${{ needs.release-package-validation.result }}
with:
script: |
const ciPassed = process.env.CI_RESULT === 'success';
const passed = ciPassed && process.env.PACKAGE_RESULT === 'success';
await github.rest.repos.createCommitStatus({
...context.repo, sha: process.env.PREPARED_SHA,
context: 'Conventional Commits', state: ciPassed ? 'success' : 'failure',
description: ciPassed ? 'PR conventions and full CI passed' : 'PR conventions or CI did not pass',
target_url: `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
});
await github.rest.repos.createCommitStatus({
...context.repo, sha: process.env.PREPARED_SHA,
context: 'Release validation', state: passed ? 'success' : 'failure',
description: passed ? 'CI and installers passed' : 'CI or installer validation did not pass',
target_url: `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
});
if (!passed) core.setFailed('Release validation failed');
packages:
needs: release-please
if: needs.release-please.outputs.release_created == 'true'
uses: ./.github/workflows/package.yml
with:
tag: ${{ needs.release-please.outputs.tag_name }}