30
30
# will have to opt in after setting up their own self-hosted runners.
31
31
32
32
jobs :
33
- # On a single Linux host, draft a release. Later, different hosts will build
34
- # for each OS/CPU in parallel, and then attach the resulting binaries to this
35
- # draft.
36
- draft_release :
37
- name : Draft release
38
- runs-on : ubuntu-latest
39
- outputs :
40
- release_id : ${{ steps.draft_release.outputs.release_id }}
41
- steps :
42
- - uses : actions/checkout@v4
43
- with :
44
- path : repo-src
45
- ref : ${{ github.ref }}
46
-
47
- - name : Draft release
48
- id : draft_release
49
- env :
50
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
51
- run : |
52
- set -e
53
- set -x
54
-
55
- # Create a draft release associated with the tag that triggered this
56
- # workflow.
57
- tag="${{ github.ref }}"
58
- (cd repo-src/api-client && npm ci)
59
- release_id=$(node ./repo-src/api-client/main.js draft-release "$tag")
60
- echo "::set-output name=release_id::$release_id"
61
-
62
33
build :
63
- needs : draft_release
64
34
uses : ./.github/workflows/build.yaml
65
35
with :
66
- release_id : ${{ needs.draft_release.outputs.release_id }}
67
36
ref : ${{ github.ref }}
68
- secrets :
69
- TOKEN : ${{ secrets.GITHUB_TOKEN }}
70
37
71
38
publish_release :
72
39
name : Publish release
73
- needs : [draft_release, build]
40
+ needs : [build]
74
41
runs-on : ubuntu-latest
42
+ permissions :
43
+ # "Write" to contents is necessary to create a release.
44
+ contents : write
75
45
steps :
76
46
- uses : actions/checkout@v4
77
47
with :
78
48
path : repo-src
79
49
ref : ${{ github.ref }}
80
50
51
+ - uses : actions/download-artifact@v4
52
+ with :
53
+ path : assets
54
+ merge-multiple : true
55
+
81
56
- name : Publish release
82
57
env :
83
58
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
@@ -93,41 +68,24 @@ jobs:
93
68
echo " - $(date -I)" >> body.txt
94
69
echo "" >> body.txt
95
70
96
- echo "$GITHUB_REPOSITORY version:" >> body.txt
97
- echo " - $repo_tag " >> body.txt
71
+ echo "${{ github.repository }} version:" >> body.txt
72
+ echo " - ${{ github.ref_name }} " >> body.txt
98
73
echo "" >> body.txt
99
74
100
75
echo "Software versions:" >> body.txt
101
76
cat repo-src/versions.txt | \
102
77
sed -e 's/^/ - /' >> body.txt
103
78
echo "" >> body.txt
104
79
105
- # Update the release notes with this preliminary version. This is
106
- # what gets emailed out when we publish the release below.
107
- release_id="${{ needs.draft_release.outputs.release_id }}"
108
- (cd repo-src/api-client && npm ci)
109
- node ./repo-src/api-client/main.js \
110
- update-release-body "$release_id" "$(cat body.txt)"
111
-
112
- # Now we have to take the release out of draft mode. Until we do, we
113
- # can't get download URLs for the assets.
114
- node ./repo-src/api-client/main.js \
115
- publish-release "$release_id"
116
-
117
- # The downloads are sometimes a bit flaky (responding with 404) if we
118
- # don't put some delay between publication and download. This number
119
- # is arbitrary, but experimentally, it seems to solve the issue.
120
- sleep 30
121
-
122
- # Next, download the assets.
123
- node ./repo-src/api-client/main.js \
124
- download-all-assets "$release_id" assets/
125
-
126
- # Now add the MD5 sums to the release notes.
80
+ # Add the MD5 sums to the release notes.
127
81
echo "MD5 sums:" >> body.txt
128
82
(cd assets; md5sum * | sed -e 's/^/ - /') >> body.txt
129
83
130
- # Now update the release notes one last time, with the MD5 sums
131
- # appended.
132
- node ./repo-src/api-client/main.js \
133
- update-release-body "$release_id" "$(cat body.txt)"
84
+ # Publish the release, including release notes and assets.
85
+ gh release create \
86
+ -R ${{ github.repository }} \
87
+ --verify-tag \
88
+ --notes-file body.txt \
89
+ --title "${{ github.ref_name }}" \
90
+ "${{ github.ref_name }}" \
91
+ assets/*
0 commit comments