8000 add: auto release with sha by Tieqiong · Pull Request #39 · diffpy/libdiffpy · GitHub
[go: up one dir, main page]

Skip to content

add: auto release with sha #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
auto release with sha after tag push
  • Loading branch information
Tieqiong committed Jun 23, 2025
commit b472d419f87a739639e5dd6242959abc94e699bb
67 changes: 67 additions & 0 deletions .github/workflows/github-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,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 }}
0