-
Notifications
You must be signed in to change notification settings - Fork 77
66 lines (62 loc) · 2.32 KB
/
append-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
# After a release is successfully published, upload extra assets to it
name: AppendRelease
# We're going to edit a gh release, so we need that permission
permissions:
contents: write
on:
# Whenever a workflow called "Release" completes, run this!
workflow_run:
workflows: ["Release"]
types:
- completed
jobs:
# Check if we should actually run by looking for the should-publish job
should-run:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
outputs:
val: ${{ steps.check.outputs.result }}
steps:
- id: check
uses: actions/github-script@v6
with:
result-encoding: string
script: |
let allRuns = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
for (const job of allRuns.data.jobs) {
if (job.name == "should-publish") {
if (job.status == "completed" && job.conclusion == "success") {
return "run"
}
}
}
return "skip"
# Generate dist-manifest-schema.json and upload it to the release
schema:
name: Add schema to release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
runs-on: ubuntu-latest
needs: ["should-run"]
if: ${{ needs.should-run.outputs.val == 'run' }}
steps:
# Setup
- uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_branch }}
fetch-depth: 0
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
# We get the tag of the release in github.event.workflow_run.head_branch
# No idea why it's stored there with that name, but, it is?
- name: Install cargo-dist and upload schema
run: |
echo "uploading schema to ${{ github.event.workflow_run.head_branch }}"
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/${{ github.event.workflow_run.head_branch }}/cargo-dist-installer.sh | sh
cargo dist manifest-schema > dist-manifest-schema.json
gh release upload ${{ github.event.workflow_run.head_branch }} dist-manifest-schema.json