Skip to content

Commit c86955c

Browse files
authored
give release action necessary permissions (#13)
Signed-off-by: Dave Dykstra <2129743+DrDaveD@users.noreply.github.com>
1 parent 6cbf940 commit c86955c

File tree

2 files changed

+126
-121
lines changed

2 files changed

+126
-121
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
name: CI
2-
on: [push, pull_request]
1+
name: ci
2+
on:
3+
pull_request:
34
jobs:
45
lint:
56
runs-on: ubuntu-latest
@@ -52,122 +53,3 @@ jobs:
5253
${{ runner.os }}-go-
5354
- name: Test
5455
run: make test
55-
release:
56-
needs:
57-
- lint
58-
- build
59-
- test
60-
runs-on: ubuntu-latest
61-
if: startsWith(github.ref, 'refs/tags/v')
62-
steps:
63-
- uses: actions/checkout@v3
64-
- name: Get tag version
65-
id: get-tag-version
66-
uses: actions/github-script@v6
67-
with:
68-
result-encoding: string
69-
script: |
70-
return context.ref.replace(/^refs\/tags\/v/, '');
71-
- uses: mindsers/changelog-reader-action@v2
72-
id: read-changelog
73-
with:
74-
version: ${{ steps.get-tag-version.outputs.result }}
75-
- uses: actions/create-release@v1
76-
id: create-release
77-
env:
78-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79-
with:
80-
tag_name: ${{ github.ref }}
81-
release_name: v${{ steps.read-changelog.outputs.version }}
82-
body: ${{ steps.read-changelog.outputs.changes }}
83-
prerelease: ${{ steps.read-changelog.outputs.status == 'prereleased' }}
84-
draft: ${{ steps.read-changelog.outputs.status == 'unreleased' }}
85-
outputs:
86-
upload-url: ${{ steps.create-release.outputs.upload_url }}
87-
release-assets:
88-
needs: release
89-
runs-on: ubuntu-latest
90-
strategy:
91-
matrix:
92-
include:
93-
- os: darwin
94-
arch: amd64
95-
- os: windows
96-
arch: amd64
97-
- os: windows
98-
arch: '386'
99-
- os: linux
100-
arch: amd64
101-
- os: linux
102-
arch: '386'
103-
- os: linux
104-
arch: arm64
105-
- os: linux
106-
arch: arm
107-
- os: freebsd
108-
arch: amd64
109-
- os: freebsd
110-
arch: '386'
111-
- os: freebsd
112-
arch: arm
113-
- os: netbsd
114-
arch: amd64
115-
- os: netbsd
116-
arch: '386'
117-
- os: openbsd
118-
arch: amd64
119-
- os: openbsd
120-
arch: '386'
121-
- os: solaris
122-
arch: amd64
123-
steps:
124-
- uses: actions/checkout@v4
125-
- uses: actions/setup-go@v5
126-
with:
127-
go-version-file: 'go.mod'
128-
- uses: actions/cache@v3
129-
with:
130-
path: |
131-
~/go/pkg/mod
132-
~/go/pkg/sumdb
133-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
134-
restore-keys: |
135-
${{ runner.os }}-go-
136-
- name: Build
137-
env:
138-
PLUGIN_DIST_OS: ${{ matrix.os }}
139-
PLUGIN_DIST_ARCH: ${{ matrix.arch }}
140-
run: |
141-
make "dist-bin-${PLUGIN_DIST_OS}-${PLUGIN_DIST_ARCH}"
142-
- name: Get asset information
143-
id: get-asset-information
144-
run: |
145-
archive_name="$( find ./artifacts/ -type f -not -name '*.sha256.asc' -printf '%f\n' )"
146-
archive_media_type="$( file -b --mime-type "./artifacts/${archive_name}" )"
147-
148-
checksum_name="${archive_name}.sha256.asc"
149-
checksum_media_type="$( file -b --mime-type "./artifacts/${checksum_name}" )"
150-
151-
echo "archive-name=${archive_name}" >>"$GITHUB_OUTPUT"
152-
echo "archive-media-type=${archive_media_type}" >>"$GITHUB_OUTPUT"
153-
154-
echo "checksum-name=${checksum_name}" >>"$GITHUB_OUTPUT"
155-
echo "checksum-media-type=${checksum_media_type}" >>"$GITHUB_OUTPUT"
156-
- name: Upload checksum asset
157-
uses: actions/upload-release-asset@v1
158-
env:
159-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
160-
with:
161-
upload_url: ${{ needs.release.outputs.upload-url }}
162-
asset_path: ./artifacts/${{ steps.get-asset-information.outputs.checksum-name }}
163-
asset_name: ${{ steps.get-asset-information.outputs.checksum-name }}
164-
asset_content_type: ${{ steps.get-asset-information.outputs.checksum-media-type }}
165-
- name: Upload archive asset
166-
uses: actions/upload-release-asset@v1
167-
env:
168-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
169-
with:
170-
upload_url: ${{ needs.release.outputs.upload-url }}
171-
asset_path: ./artifacts/${{ steps.get-asset-information.outputs.archive-name }}
172-
asset_name: ${{ steps.get-asset-information.outputs.archive-name }}
173-
asset_content_type: ${{ steps.get-asset-information.outputs.archive-media-type }}

.github/workflows/release.yml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: release
2+
on:
3+
push:
4+
tags:
5+
- 'v*.*.*'
6+
permissions:
7+
contents: write
8+
jobs:
9+
create-release:
10+
runs-on: ubuntu-latest
11+
if: startsWith(github.ref, 'refs/tags/v')
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Get tag version
15+
id: get-tag-version
16+
uses: actions/github-script@v6
17+
with:
18+
result-encoding: string
19+
script: |
20+
return context.ref.replace(/^refs\/tags\/v/, '');
21+
- uses: mindsers/changelog-reader-action@v2
22+
id: read-changelog
23+
with:
24+
version: ${{ steps.get-tag-version.outputs.result }}
25+
- uses: actions/create-release@v1
26+
id: create-release
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
with:
30+
tag_name: ${{ github.ref }}
31+
release_name: v${{ steps.read-changelog.outputs.version }}
32+
body: ${{ steps.read-changelog.outputs.changes }}
33+
prerelease: ${{ steps.read-changelog.outputs.status == 'prereleased' }}
34+
draft: ${{ steps.read-changelog.outputs.status == 'unreleased' }}
35+
outputs:
36+
upload-url: ${{ steps.create-release.outputs.upload_url }}
37+
release-assets:
38+
needs: create-release
39+
runs-on: ubuntu-latest
40+
strategy:
41+
matrix:
42+
include:
43+
- os: darwin
44+
arch: amd64
45+
- os: windows
46+
arch: amd64
47+
- os: windows
48+
arch: '386'
49+
- os: linux
50+
arch: amd64
51+
- os: linux
52+
arch: '386'
53+
- os: linux
54+
arch: arm64
55+
- os: linux
56+
arch: arm
57+
- os: freebsd
58+
arch: amd64
59+
- os: freebsd
60+
arch: '386'
61+
- os: freebsd
62+
arch: arm
63+
- os: netbsd
64+
arch: amd64
65+
- os: netbsd
66+
arch: '386'
67+
- os: openbsd
68+
arch: amd64
69+
- os: openbsd
70+
arch: '386'
71+
- os: solaris
72+
arch: amd64
73+
steps:
74+
- uses: actions/checkout@v4
75+
- uses: actions/setup-go@v5
76+
with:
77+
go-version-file: 'go.mod'
78+
- uses: actions/cache@v3
79+
with:
80+
path: |
81+
~/go/pkg/mod
82+
~/go/pkg/sumdb
83+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
84+
restore-keys: |
85+
${{ runner.os }}-go-
86+
- name: Build
87+
env:
88+
PLUGIN_DIST_OS: ${{ matrix.os }}
89+
PLUGIN_DIST_ARCH: ${{ matrix.arch }}
90+
run: |
91+
make "dist-bin-${PLUGIN_DIST_OS}-${PLUGIN_DIST_ARCH}"
92+
- name: Get asset information
93+
id: get-asset-information
94+
run: |
95+
archive_name="$( find ./artifacts/ -type f -not -name '*.sha256.asc' -printf '%f\n' )"
96+
archive_media_type="$( file -b --mime-type "./artifacts/${archive_name}" )"
97+
98+
checksum_name="${archive_name}.sha256.asc"
99+
checksum_media_type="$( file -b --mime-type "./artifacts/${checksum_name}" )"
100+
101+
echo "archive-name=${archive_name}" >>"$GITHUB_OUTPUT"
102+
echo "archive-media-type=${archive_media_type}" >>"$GITHUB_OUTPUT"
103+
104+
echo "checksum-name=${checksum_name}" >>"$GITHUB_OUTPUT"
105+
echo "checksum-media-type=${checksum_media_type}" >>"$GITHUB_OUTPUT"
106+
- name: Upload checksum asset
107+
uses: actions/upload-release-asset@v1
108+
env:
109+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
110+
with:
111+
upload_url: ${{ needs.create-release.outputs.upload-url }}
112+
asset_path: ./artifacts/${{ steps.get-asset-information.outputs.checksum-name }}
113+
asset_name: ${{ steps.get-asset-information.outputs.checksum-name }}
114+
asset_content_type: ${{ steps.get-asset-information.outputs.checksum-media-type }}
115+
- name: Upload archive asset
116+
uses: actions/upload-release-asset@v1
117+
env:
118+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
119+
with:
120+
upload_url: ${{ needs.create-release.outputs.upload-url }}
121+
asset_path: ./artifacts/${{ steps.get-asset-information.outputs.archive-name }}
122+
asset_name: ${{ steps.get-asset-information.outputs.archive-name }}
123+
asset_content_type: ${{ steps.get-asset-information.outputs.archive-media-type }}

0 commit comments

Comments
 (0)