Repository navigation
80 lines (70 loc) · 3.24 KB
/
Copy pathpublish-github-release.yml
File metadata and controls
80 lines (70 loc) · 3.24 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
name: Publish GitHub release
# Craft creates the approved tag through the GitHub API before it publishes npm.
on:
create:
workflow_dispatch:
inputs:
tag:
description: Existing approved release tag to retry (for example, 0.227.0)
required: true
type: string
permissions:
contents: read
actions: read
concurrency:
group: github-release-${{ inputs.tag || github.event.ref }}
cancel-in-progress: false
jobs:
publish:
if: github.repository == 'getsentry/junior' && (github.event_name == 'workflow_dispatch' || github.event.ref_type == 'tag')
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 30
env:
RELEASE_TAG: ${{ inputs.tag || github.event.ref }}
steps:
- name: Validate release tag
run: |
if [[ ! "$RELEASE_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
echo "Expected an exact release tag" >&2
exit 1
fi
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
ref: refs/tags/${{ env.RELEASE_TAG }}
fetch-depth: 0
persist-credentials: false
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
with:
run_install: false
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: "24.22.1"
- name: Download the checked CI artifact for this commit
env:
GH_TOKEN: ${{ github.token }}
run: |
sha=$(git rev-parse HEAD)
# Craft selects artifacts by commit name, not by successful run. Refuse
# ambiguity instead of picking different bytes after a CI rerun.
artifacts=$(gh api "repos/$GITHUB_REPOSITORY/actions/artifacts?name=$sha&per_page=100")
if ! jq -e --arg sha "$sha" '.total_count == 1 and (.artifacts | length == 1) and .artifacts[0].name == $sha and .artifacts[0].expired == false and .artifacts[0].workflow_run.head_sha == $sha' <<< "$artifacts" > /dev/null; then
echo "Expected one unexpired CI artifact for $sha. Stop for manual review; do not rebuild or select different bytes." >&2
exit 1
fi
run=$(jq -r '.artifacts[0].workflow_run.id' <<< "$artifacts")
gh api "repos/$GITHUB_REPOSITORY/actions/runs/$run" |
jq -e --arg sha "$sha" '.head_sha == $sha and .event == "push" and .path == ".github/workflows/ci.yml" and .status == "completed" and .conclusion == "success"' > /dev/null
gh run download "$run" --repo "$GITHUB_REPOSITORY" --name "$sha" --dir artifacts
node scripts/release-artifacts.mjs verify artifacts
# Use the app token so release.published can trigger downstream workflows.
- name: Get release token
id: token
uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349 # v2
with:
app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }}
private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }}
permission-contents: write
- name: Verify and publish GitHub release
env:
GH_TOKEN: ${{ steps.token.outputs.token }}
run: node scripts/publish-github-release.mjs "$RELEASE_TAG" artifacts