docs: move cancellation docs into docs/03_Usage.md so they survive RE… #186
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: Release | ||
| on: | ||
| workflow_run: | ||
| workflows: [Build] | ||
| types: [completed] | ||
| branches: [main] | ||
| permissions: | ||
| contents: write | ||
| releases: write | ||
| defaults: | ||
| run: | ||
| shell: bash | ||
| jobs: | ||
| check_commit: | ||
| name: Check Commit | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| IS_RELEASE: ${{ steps.check_msg.outputs.IS_RELEASE }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.event.workflow_run.head_sha }} | ||
| - name: Check latest commit message | ||
| id: check_msg | ||
| run: | | ||
| LATEST_COMMIT_MSG=$(git log -1 --pretty=%B) | ||
| if echo "$LATEST_COMMIT_MSG" | grep -q "Release Prep v"; then | ||
| echo "IS_RELEASE=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "IS_RELEASE=false" >> $GITHUB_OUTPUT | ||
| fi | ||
| release: | ||
| name: Release | ||
| needs: [check_commit] | ||
| if: ${{ needs.check_commit.outputs.IS_RELEASE == 'true' }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| ref: ${{ github.event.workflow_run.head_sha }} | ||
| - name: Download artifact | ||
| uses: dawidd6/action-download-artifact@v6 | ||
| with: | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| workflow: build.yml | ||
| workflow_conclusion: success | ||
| name: wasm-file | ||
| - name: Extract version from commit message | ||
| id: extract-version | ||
| run: | | ||
| VERSION=$(git log -1 --pretty=%B | grep -oP 'Release Prep \Kv[0-9]+\.[0-9]+\.[0-9]+') | ||
| echo "Extracted version: $VERSION" | ||
| echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
| - name: Calculate sha256 | ||
| run: | | ||
| SHA256_HASH=$(sha256sum plugin.wasm | awk '{ print $1 }') | ||
| echo "SHA256_HASH=${SHA256_HASH}" >> $GITHUB_ENV | ||
| - name: Reconstruct release notes from PRs | ||
| id: notes | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| OWNER="${{ github.repository_owner }}" | ||
| REPO="${{ github.event.repository.name }}" | ||
| VERSION=${{ steps.extract-version.outputs.version }} | ||
| PREVIOUS_TAG=$(git tag --sort=-v:refname | head -1) | ||
| if [ -z "$PREVIOUS_TAG" ]; then | ||
| COMMITS=$(git log --oneline --grep="Merge pull request" --grep="#[0-9]" -E) | ||
| else | ||
| COMMITS=$(git log ${PREVIOUS_TAG}..HEAD --oneline --grep="Merge pull request" --grep="#[0-9]" -E) | ||
| fi | ||
| NOTES_FILE=$(mktemp) | ||
| echo "notes-file=$NOTES_FILE" >> $GITHUB_OUTPUT | ||
| cat > "$NOTES_FILE" <<- ENDOFNOTE | ||
| ## Release ${VERSION} | ||
| Release sha256 is \`${SHA256_HASH}\` | ||
| ## Configuration example | ||
| \`\`\`yaml | ||
| version: '2' | ||
| plugins: | ||
| - name: csharp | ||
| wasm: | ||
| url: https://github.com/${{ github.repository }}/releases/download/${VERSION}/sqlc-gen-csharp.wasm | ||
| sha256: ${SHA256_HASH} | ||
| \`\`\` | ||
| ## Changelog | ||
| ENDOFNOTE | ||
| while IFS= read -r commit; do | ||
| PR_NUM=$(echo "$commit" | grep -oE '#[0-9]+' | tr -d '#' || echo "") | ||
| if [ -n "$PR_NUM" ]; then | ||
| PR_TITLE=$(gh api repos/$OWNER/$REPO/pulls/$PR_NUM --jq '.title' 2>/dev/null || echo "PR #$PR_NUM") | ||
| echo "- $PR_TITLE (#$PR_NUM)" >> "$NOTES_FILE" | ||
| fi | ||
| done <<< "$COMMITS" | ||
| echo "" >> "$NOTES_FILE" | ||
| echo "## Contributors" >> "$NOTES_FILE" | ||
| echo "* @SockworkOrange" >> "$NOTES_FILE" | ||
| - name: Create release and upload asset | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| NEW_TAG=${{ steps.extract-version.outputs.version }} | ||
| mv plugin.wasm sqlc-gen-csharp.wasm | ||
| echo "Creating release ${NEW_TAG}..." | ||
| gh release create ${NEW_TAG} \ | ||
| sqlc-gen-csharp.wasm \ | ||
| --title "${NEW_TAG}" \ | ||
| --notes-file "${{ steps.notes.outputs.notes-file }}" | ||
| echo "Release ${NEW_TAG} published successfully" | ||