mirror of
https://github.com/h-sphere/sql-seal.git
synced 2026-07-22 10:10:28 +00:00
Merge pull request #59 from h-sphere/chore/tag-auto-publish
chore: autoreleasing new versions
This commit is contained in:
commit
33673bfff8
2 changed files with 81 additions and 2 deletions
41
.github/workflows/publish.yml
vendored
41
.github/workflows/publish.yml
vendored
|
|
@ -21,6 +21,26 @@ jobs:
|
|||
- name: Build plugin
|
||||
run: |
|
||||
npm run build
|
||||
- name: Extract release notes
|
||||
id: release-notes
|
||||
run: |
|
||||
tag="${GITHUB_REF#refs/tags/}"
|
||||
# Remove 'v' prefix if present for matching
|
||||
version="${tag#v}"
|
||||
|
||||
awk -v version="$version" '
|
||||
BEGIN { found=0; content="" }
|
||||
/^# [0-9]+\.[0-9]+\.[0-9]+/ {
|
||||
if (found) { exit }
|
||||
if ($2 ~ "^"version"($| \\()") { found=1; next }
|
||||
}
|
||||
found { content = content $0 "\n" }
|
||||
END { printf "%s", content }
|
||||
' CHANGELOG.md > release_notes.txt
|
||||
|
||||
echo "NOTES<<EOF" >> $GITHUB_OUTPUT
|
||||
cat release_notes.txt >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
- name: Create release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
|
@ -29,5 +49,22 @@ jobs:
|
|||
|
||||
gh release create "$tag" \
|
||||
--title="$tag" \
|
||||
--draft \
|
||||
main.js manifest.json styles.css
|
||||
--notes="${{ steps.release-notes.outputs.NOTES }}" \
|
||||
main.js manifest.json styles.css
|
||||
|
||||
echo "RELEASE_URL=$(gh release view $tag --json url -q .url)" >> $GITHUB_OUTPUT
|
||||
- name: Send Discord notification
|
||||
if: success() && github.event_name != 'pull_request'
|
||||
env:
|
||||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
||||
run: |
|
||||
tag="${GITHUB_REF#refs/tags/}"
|
||||
|
||||
MESSAGE="🎉 New release $tag is now available!\n\n"
|
||||
MESSAGE+="📝 Changes:\n"
|
||||
MESSAGE+="${{ steps.release-notes.outputs.NOTES }}\n"
|
||||
MESSAGE+="\n🔗 Release: ${{ steps.create-release.outputs.RELEASE_URL }}"
|
||||
|
||||
curl -H "Content-Type: application/json" \
|
||||
-d "{\"content\": \"$MESSAGE\"}" \
|
||||
$DISCORD_WEBHOOK
|
||||
42
.github/workflows/tag.yml
vendored
Normal file
42
.github/workflows/tag.yml
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
name: Auto Tag on Version Change
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'package.json'
|
||||
|
||||
jobs:
|
||||
check-and-tag:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Get package version
|
||||
id: package-version
|
||||
run: |
|
||||
VERSION=$(node -p "require('./package.json').version")
|
||||
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Check if tag exists
|
||||
id: check-tag
|
||||
run: |
|
||||
if git rev-parse "${{ steps.package-version.outputs.VERSION }}" >/dev/null 2>&1; then
|
||||
echo "EXISTS=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "EXISTS=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Create and push tag
|
||||
if: steps.check-tag.outputs.EXISTS == 'false'
|
||||
run: |
|
||||
git config user.name "GitHub Actions"
|
||||
git config user.email "actions@github.com"
|
||||
git tag -a "${{ steps.package-version.outputs.VERSION }}" -m "Release version ${{ steps.package-version.outputs.VERSION }}"
|
||||
git push origin "${{ steps.package-version.outputs.VERSION }}"
|
||||
Loading…
Reference in a new issue