-
Notifications
You must be signed in to change notification settings - Fork 16
67 lines (57 loc) · 1.87 KB
/
github-release.yml
File metadata and controls
67 lines (57 loc) · 1.87 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
name: "Tag-based Release with SHA256"
on:
push:
tags:
- '*'
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout libdiffpy
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check permission
id: perm
uses: actions/github-script@v6
with:
result-encoding: string
script: |
const { data } = await github.rest.repos.getCollaboratorPermissionLevel({
owner: context.repo.owner,
repo: context.repo.repo,
username: context.actor
});
return data.permission
- name: Fail if not maintainer/admin
if: ${{ steps.perm.outputs.result != 'maintain' && steps.perm.outputs.result != 'admin' }}
run: |
echo "${{ github.actor }} is not a maintainer or admin"
exit 1
- name: Download tarball
run: |
curl -L "https://codeload.github.com/${{ github.repository }}/tar.gz/${{ github.ref_name }}" \
-o source.tar.gz
- name: Compute SHA256
id: sha
run: |
shasum=$(openssl sha256 source.tar.gz | awk '{print $2}')
echo "sha=$shasum" >> $GITHUB_OUTPUT
- name: Get tag message
id: tagmsg
run: |
TAG=${GITHUB_REF##*/}
message=$(git tag -l --format='%(contents)' "$TAG")
echo "tag_message<<EOF" >> $GITHUB_OUTPUT
echo "$message" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
body: |
${{ steps.tagmsg.outputs.tag_message }}
SHA256 (tar.gz): ${{ steps.sha.outputs.sha }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}