From ad637a7d187e1615c4555b0c3365ed77360fbbf6 Mon Sep 17 00:00:00 2001 From: "Joshua J. Bouw" Date: Tue, 26 May 2026 02:18:09 +0400 Subject: [PATCH] ci: add release workflow (GitHub Release notes on tag push) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mirrors sdk-rust's release.yml shape: - Triggers on `v[0-9]+.*` tag push. - Extracts the [] section from CHANGELOG.md as the release body. - Lists contributing Astrinauts (commit authors since the previous tag) with their GitHub @-handles where resolvable. - Does NOT auto-publish to npm — manual `npm publish` per package keeps the publish step deliberate, matching sdk-rust's manual `cargo workspaces publish` pattern. Without this, tagging `v0.1.0` would produce only a bare tag with no GitHub Release entry, so users wouldn't see the release on the repo page and the CHANGELOG body wouldn't render in the UI. --- .github/workflows/release.yml | 72 +++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) 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..98373aa --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,72 @@ +name: Release + +on: + push: + tags: + - 'v[0-9]+.*' + +permissions: + contents: write + +jobs: + github-release: + name: GitHub Release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Extract changelog for this version + id: changelog + run: | + VERSION="${GITHUB_REF_NAME#v}" + BODY=$(awk "/^## \\[$VERSION\\]/{found=1; next} /^## \\[/{if(found) exit} found" CHANGELOG.md) + if [ -z "$BODY" ]; then + BODY="See [CHANGELOG.md](https://github.com/unicity-astrid/sdk-js/blob/${GITHUB_REF_NAME}/CHANGELOG.md) for details." + fi + { + echo "body<> "$GITHUB_OUTPUT" + + - name: Compile Astrinauts for this release + id: contributors + env: + GH_TOKEN: ${{ github.token }} + run: | + PREV_TAG=$(git tag --sort=-v:refname | sed -n '2p') + if [ -z "$PREV_TAG" ]; then + AUTHORS=$(git log --format='%aN' | sort -u) + else + AUTHORS=$(git log --format='%aN' "$PREV_TAG"..HEAD | sort -u) + fi + ASTRINAUTS="" + while IFS= read -r name; do + [ -z "$name" ] && continue + # Try to resolve GitHub username from commit email + EMAIL=$(git log --format='%aE' --author="$name" -1) + USERNAME=$(gh api "search/users?q=$EMAIL+in:email" --jq '.items[0].login // empty' 2>/dev/null || true) + if [ -n "$USERNAME" ]; then + ASTRINAUTS="${ASTRINAUTS}\n- @${USERNAME}" + else + ASTRINAUTS="${ASTRINAUTS}\n- ${name}" + fi + done <<< "$AUTHORS" + { + echo "list<> "$GITHUB_OUTPUT" + + - name: Create release + uses: softprops/action-gh-release@v2 + with: + body: | + ${{ steps.changelog.outputs.body }} + + --- + + **With many thanks from the following Astrinauts** 🚀 + ${{ steps.contributors.outputs.list }}