Skip to content
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
45 changes: 45 additions & 0 deletions .github/workflows/checksum.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Release checksum

# Publishes the SHA-256 of the tag archive as the release asset `module.sha256`, which the
# `pollora:make:*` commands check before they extract a download (Pollora 13.45.1+).

on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: Tag of an existing release
required: true
type: string

permissions: {}

jobs:
checksum:
name: module.sha256
runs-on: ubuntu-latest
permissions:
contents: write
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
TAG: ${{ inputs.tag || github.event.release.tag_name }}
steps:
- name: Publish the checksum of the tag archive
run: |
set -euo pipefail

assets="$(gh release view "$TAG" --repo "$REPO" --json assets --jq '.assets[].name')"
if grep -qx 'module.sha256' <<< "$assets"; then
echo "module.sha256 is already published for $TAG: left as it is."
exit 0
fi

url="https://github.com/$REPO/archive/refs/tags/$TAG.zip"
curl -fsSL --retry 3 "$url" -o first.zip
curl -fsSL --retry 3 "$url" -o second.zip
cmp first.zip second.zip

printf '%s %s.zip\n' "$(sha256sum first.zip | cut -d' ' -f1)" "$TAG" > module.sha256
gh release upload "$TAG" module.sha256 --repo "$REPO"
Loading