Merge pull request #1443 from mattn/add-release-workflow
Add workflow to create releases on tag push
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
new file mode 100644
index 0000000..5db21a2
--- /dev/null
+++ b/.github/workflows/release.yaml
@@ -0,0 +1,38 @@
+name: Release
+
+on:
+ push:
+ tags:
+ - 'v*'
+
+permissions:
+ contents: write
+
+concurrency:
+ group: release-${{ github.ref }}
+ cancel-in-progress: false
+
+jobs:
+ release:
+ name: Create release
+ runs-on: ubuntu-latest
+ steps:
+ - name: Create release with generated notes
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ set -euo pipefail
+ if output=$(gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" 2>&1); then
+ echo "Release $GITHUB_REF_NAME already exists, skipping"
+ exit 0
+ elif ! grep -qi "release not found" <<< "$output"; then
+ # A lookup failure other than "not found" (auth, network, API)
+ # must not fall through to the create step.
+ echo "$output" >&2
+ exit 1
+ fi
+ gh release create "$GITHUB_REF_NAME" \
+ --repo "$GITHUB_REPOSITORY" \
+ --title "${GITHUB_REF_NAME#v}" \
+ --verify-tag \
+ --generate-notes