Skip to content

Commit b472d41

Browse files
committed
auto release with sha after tag push
1 parent fd7a40f commit b472d41

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

.github/workflows/github-release.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: "Tag-based Release with SHA256"
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
13+
- name: Checkout libdiffpy
14+
uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Check permission
19+
id: perm
20+
uses: actions/github-script@v6
21+
with:
22+
result-encoding: string
23+
script: |
24+
const { data } = await github.rest.repos.getCollaboratorPermissionLevel({
25+
owner: context.repo.owner,
26+
repo: context.repo.repo,
27+
username: context.actor
28+
});
29+
return data.permission
30+
31+
- name: Fail if not maintainer/admin
32+
if: ${{ steps.perm.outputs.result != 'maintain' && steps.perm.outputs.result != 'admin' }}
33+
run: |
34+
echo "${{ github.actor }} is not a maintainer or admin"
35+
exit 1
36+
37+
- name: Download tarball
38+
run: |
39+
curl -L "https://codeload.github.com/${{ github.repository }}/tar.gz/${{ github.ref_name }}" \
40+
-o source.tar.gz
41+
42+
- name: Compute SHA256
43+
id: sha
44+
run: |
45+
shasum=$(openssl sha256 source.tar.gz | awk '{print $2}')
46+
echo "sha=$shasum" >> $GITHUB_OUTPUT
47+
48+
- name: Get tag message
49+
id: tagmsg
50+
run: |
51+
TAG=${GITHUB_REF##*/}
52+
message=$(git tag -l --format='%(contents)' "$TAG")
53+
echo "tag_message<<EOF" >> $GITHUB_OUTPUT
54+
echo "$message" >> $GITHUB_OUTPUT
55+
echo "EOF" >> $GITHUB_OUTPUT
56+
57+
- name: Create GitHub Release
58+
uses: softprops/action-gh-release@v1
59+
with:
60+
tag_name: ${{ github.ref_name }}
61+
name: Release ${{ github.ref_name }}
62+
body: |
63+
${{ steps.tagmsg.outputs.tag_message }}
64+
65+
SHA256 (tar.gz): ${{ steps.sha.outputs.sha }}
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)