From 0a13c837aed4fb6ecaa55d7b0e07a4e6594bfca2 Mon Sep 17 00:00:00 2001 From: Louis J <132601011+louisjoecodes@users.noreply.github.com> Date: Tue, 16 Jan 2024 19:13:09 -0800 Subject: [PATCH] chore: disable manual triggering --- .github/workflows/release.yml | 57 +++++++++++++++++++++++++++++++++++ README.md | 18 ++++++++++- 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..164de9e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,57 @@ +name: Post-Release SHA-256 Hash Calculation +on: + release: + types: [published] +jobs: + calculate-hash: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + - name: Fetch Release Assets + id: fetch-assets + uses: actions/github-script@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + script: | + const fs = require('fs'); + + const response = await github.rest.repos.listReleaseAssets({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: context.payload.release.id + }); + + const assets = response.data.map(asset => ({ url: asset.url, name: asset.name })); + fs.writeFileSync('assets.json', JSON.stringify(assets)); + + - name: Download and Calculate SHA-256 Hashes + run: | + mkdir -p downloads + echo "File Name | SHA-256 Hash" >> SHA256SUMS.txt + echo "--------- | ------------" >> SHA256SUMS.txt + jq -c '.[]' assets.json | while read -r asset; do + url=$(echo $asset | jq -r '.url') + name=$(echo $asset | jq -r '.name') + curl -L -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/octet-stream" -o "downloads/$name" "$url" + echo "Calculating SHA-256 for $name" + hash=$(sha256sum "downloads/$name" | awk '{print $1}') + echo "$name | $hash" >> SHA256SUMS.txt + done + - name: Update Release Description with SHA-256 Hashes + uses: actions/github-script@v5 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const fs = require('fs'); + const sha256sums = fs.readFileSync('SHA256SUMS.txt', 'utf8'); + const { owner, repo } = context.repo; + const release = context.payload.release; + const newBody = release.body + '\n\n### SHA-256 Hashes\n' + sha256sums; + await github.rest.repos.updateRelease({ + owner, + repo, + release_id: release.id, + body: newBody + }); diff --git a/README.md b/README.md index d2c2322..5ca6190 100644 --- a/README.md +++ b/README.md @@ -1 +1,17 @@ -# Quary CLI +

+ + + + + +

Quary CLI

+ +

+ +

+ + + +

+ +Learn more at [https://www.quary.dev](https://www.quary.dev)