name: Build Release Draft on: workflow_call: inputs: tag: type: string required: true sha: description: Commit already verified before tagging type: string required: true workflow_dispatch: inputs: tag: description: Existing draft tag to rebuild (e.g. v0.24.0) required: true type: string concurrency: group: release-draft-${{ inputs.tag }} cancel-in-progress: false permissions: contents: write jobs: resolve: runs-on: ubuntu-latest outputs: sha: ${{ steps.resolve.outputs.sha }} steps: - uses: actions/checkout@v4 with: ref: refs/tags/${{ inputs.tag }} fetch-depth: 0 - name: Verify the tag, version and approved commit id: resolve env: TAG: ${{ inputs.tag }} APPROVED_SHA: ${{ inputs.sha }} run: | CURRENT_SHA=$(git rev-parse HEAD) python3 scripts/release/release.py check --tag "$TAG" --sha "${APPROVED_SHA:-$CURRENT_SHA}" echo "sha=$CURRENT_SHA" >> "$GITHUB_OUTPUT" test: needs: resolve if: github.event_name == 'workflow_dispatch' && inputs.sha == '' uses: ./.github/workflows/test.yaml with: ref: ${{ needs.resolve.outputs.sha }} release: needs: [resolve, test] if: always() && needs.resolve.result == 'success' && (needs.test.result == 'success' || needs.test.result == 'skipped') runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 with: ref: ${{ needs.resolve.outputs.sha }} fetch-depth: 0 - name: Require an unpublished draft env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} TAG: ${{ inputs.tag }} run: test "$(gh release view "$TAG" --json isDraft --jq .isDraft)" = true - name: Set up Go uses: actions/setup-go@v5 with: go-version-file: go.mod - name: Set up pnpm uses: pnpm/action-setup@v4 with: version: 12.6.0 - name: Set up Node.js uses: actions/setup-node@v4 with: node-version: "22" cache: "pnpm" cache-dependency-path: ui/pnpm-lock.yaml - name: Build UI assets run: cd ui && pnpm install --frozen-lockfile && pnpm run build - name: Create UI archive and reviewed release notes env: TAG: ${{ inputs.tag }} run: | tar czf skillshare-ui-dist.tar.gz -C ui/dist . # GoReleaser refuses a dirty tree. Exclude the archive locally, since a rebuild checks out # an existing tag whose .gitignore cannot change. echo /skillshare-ui-dist.tar.gz >> .git/info/exclude python3 scripts/release/release.py notes --tag "$TAG" > "$RUNNER_TEMP/release-notes.md" - name: Build and upload draft assets uses: goreleaser/goreleaser-action@v6 with: version: v2.18.2 args: release --clean --release-notes=${{ runner.temp }}/release-notes.md env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Verify and upload the Homebrew formula and complete checksums env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} TAG: ${{ inputs.tag }} run: | python3 scripts/release/release.py prepare-assets --assets dist python3 scripts/release/release.py verify-assets --tag "$TAG" --assets dist gh release upload "$TAG" dist/skillshare.rb dist/checksums.txt --clobber - name: Add contributors to release notes env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} TAG: ${{ inputs.tag }} run: | PREV_TAG=$(git describe --tags --abbrev=0 "${TAG}^" 2>/dev/null || true) if [ -z "$PREV_TAG" ]; then echo "No previous tag found, skipping contributors" exit 0 fi # Get unique GitHub logins between tags (exclude bots and maintainer) LOGINS=$(gh api "repos/${GITHUB_REPOSITORY}/compare/${PREV_TAG}...${TAG}" \ --jq '[.commits[].author.login // empty] | unique | .[]' 2>/dev/null \ | grep -v '\[bot\]$' \ | grep -v '^runkids$' || true) if [ -z "$LOGINS" ]; then echo "No external contributors found, skipping" exit 0 fi # Format as @mentions and render release notes from template CONTRIBUTORS=$(echo "$LOGINS" | sed 's/^/@/' | paste -sd ', ' -) GORELEASER_BODY=$(gh release view "$TAG" --json body -q .body) export GORELEASER_BODY CONTRIBUTORS envsubst '${GORELEASER_BODY} ${CONTRIBUTORS}' < .github/RELEASE_TEMPLATE.md > release-notes.md gh release edit "$TAG" --notes-file release-notes.md rm -f release-notes.md