Release #21
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_dispatch: | |
| permissions: write-all | |
| jobs: | |
| deploy: | |
| name: Deploy | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: './go.mod' | |
| - name: Build plugin | |
| working-directory: plugin | |
| run: GOOS=wasip1 GOARCH=wasm go build -o ../sqlc-gen-better-python.wasm | |
| - name: Calculate SHA256 hash | |
| id: hash | |
| run: | | |
| HASH=$(sha256sum sqlc-gen-better-python.wasm | awk '{ print $1 }') | |
| echo "sha256=$HASH" >> $GITHUB_OUTPUT | |
| - name: Get the latest version | |
| id: latest | |
| uses: miniscruff/changie-action@v2 | |
| with: | |
| version: latest | |
| args: latest | |
| - name: Create tag | |
| id: tag | |
| run: | | |
| git tag ${{ steps.latest.outputs.output }} | |
| git push origin ${{ steps.latest.outputs.output }} | |
| DOWNLOAD_URL="https://github.com/rayakame/sqlc-gen-better-python/releases/download/${{ steps.latest.outputs.output }}/sqlc-gen-better-python.wasm" | |
| echo "download_url=$DOWNLOAD_URL" >> $GITHUB_OUTPUT | |
| - name: Update README with new version and checksum | |
| run: | | |
| sed -i -E "s|(url: ).*|url: ${{ steps.tag.outputs.download_url }}|" README.md | |
| sed -i -E "s|(sha256: ).*|sha256: ${{ steps.hash.outputs.sha256 }}|" README.md | |
| - name: Create PR to update README | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| commit-message: "chore: update README example with v${{ steps.latest.outputs.output }}" | |
| branch: "release/update-readme-${{ steps.latest.outputs.output }}" | |
| title: "Update README for release ${{ steps.latest.outputs.output }}" | |
| labels: skip-fragment-check | |
| add-paths: | | |
| README.md | |
| body: | | |
| This PR updates the README example config with: | |
| - WASM plugin version: `${{ steps.latest.outputs.output }}` | |
| - SHA256 checksum: `${{ steps.hash.outputs.sha256 }}` | |
| Auto-generated during the release workflow. | |
| - name: Generate release description | |
| run: | | |
| export checksum=${{ steps.hash.outputs.sha256 }} | |
| export download_url=${{ steps.tag.outputs.download_url }} | |
| yq -i '.plugins[0].wasm.url = env(download_url)' .github/release_output_template.yaml | |
| yq -i '.plugins[0].wasm.sha256 = env(checksum)' .github/release_output_template.yaml | |
| # Create the release body with the warning message at the top | |
| echo "> [!WARNING]" > release_body.md | |
| echo "> Every Release before \`v1.0.0\`, including this one is an **early alpha release**. These versions are only released for interested people who want to test this plugin and help make it better." >> release_body.md | |
| # Add the release changelog and YAML content below the warning message | |
| cat .changes/${{ steps.latest.outputs.output }}.md >> release_body.md | |
| echo "\`\`\`yaml" >> release_body.md | |
| cat .github/release_output_template.yaml >> release_body.md | |
| echo "\`\`\`" >> release_body.md | |
| - name: Create release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| name: "${{ steps.latest.outputs.output }}" | |
| tag_name: "refs/tags/${{ steps.latest.outputs.output }}" | |
| body_path: release_body.md | |
| files: ./sqlc-gen-better-python.wasm |