ci-build: rebuild dist ( 3 files changed, 25 insertions(+), 11 deleti… #43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Tag Latest | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "dist/**" | |
| workflow_dispatch: {} | |
| workflow_call: {} | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set variables | |
| id: vars | |
| run: | | |
| SHA=$(git rev-parse HEAD) | |
| SHORT=$(git rev-parse --short HEAD) | |
| UTC=$(date -u +%Y%m%dT%H%M%SZ) | |
| DATED_TAG="${UTC}-${SHORT}" | |
| echo "sha=$SHA" >> "$GITHUB_OUTPUT" | |
| echo "short=$SHORT" >> "$GITHUB_OUTPUT" | |
| echo "dated_tag=$DATED_TAG" >> "$GITHUB_OUTPUT" | |
| - name: Push tags | |
| run: | | |
| git tag -f latest HEAD | |
| git tag "${{ steps.vars.outputs.dated_tag }}" HEAD | |
| git push origin latest "${{ steps.vars.outputs.dated_tag }}" --force | |
| - name: Compute content hashes | |
| id: hash | |
| run: | | |
| # Tag tarball hash (same URL bun fetches) | |
| TARBALL_URL="https://github.com/${{ github.repository }}/archive/refs/tags/latest.tar.gz" | |
| for i in 1 2 3 4 5; do | |
| TAG_HASH=$(curl -sL "$TARBALL_URL" | openssl dgst -sha512 -binary | openssl base64 -A) | |
| if [ -n "$TAG_HASH" ]; then break; fi | |
| echo "Attempt $i: empty hash, retrying in 2s..." | |
| sleep 2 | |
| done | |
| TAG_SRI="sha512-${TAG_HASH}" | |
| # Commit SHA tarball hash | |
| SHA_URL="https://github.com/${{ github.repository }}/archive/${GITHUB_SHA}.tar.gz" | |
| SHA_HASH=$(curl -sL "$SHA_URL" | openssl dgst -sha512 -binary | openssl base64 -A) | |
| SHA_SRI="sha512-${SHA_HASH}" | |
| echo "content_hash=$TAG_SRI" >> "$GITHUB_OUTPUT" | |
| echo "commit_hash=$SHA_SRI" >> "$GITHUB_OUTPUT" | |
| - name: Create dated release (marked as latest) | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_TOKEN || github.token }} | |
| run: | | |
| gh release create "${{ steps.vars.outputs.dated_tag }}" \ | |
| --title "${{ steps.vars.outputs.dated_tag }}" \ | |
| --latest \ | |
| --notes "${{ steps.hash.outputs.content_hash }} | |
| ${{ steps.hash.outputs.commit_hash }} | |
| Commit: ${{ steps.vars.outputs.sha }} | |
| Repository: https://github.com/${{ github.repository }}" | |
| - name: Create/update latest release (not marked as latest) | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_TOKEN || github.token }} | |
| run: | | |
| # Delete existing latest release if present | |
| gh release delete latest --yes 2>/dev/null || true | |
| gh release create latest \ | |
| --title "latest" \ | |
| --notes "${{ steps.hash.outputs.content_hash }} | |
| ${{ steps.hash.outputs.commit_hash }} | |
| Commit: ${{ steps.vars.outputs.sha }} | |
| Points to same content as ${{ steps.vars.outputs.dated_tag }}" |