mirror of
https://github.com/h-sphere/sql-seal.git
synced 2026-07-22 10:10:28 +00:00
chore: new release mechanism with changesets
This commit is contained in:
parent
960c7cce24
commit
74f9321362
4 changed files with 74 additions and 60 deletions
59
.github/workflows/publish.yml
vendored
59
.github/workflows/publish.yml
vendored
|
|
@ -1,59 +0,0 @@
|
|||
name: Publish
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [CI]
|
||||
branches: [main]
|
||||
types: [completed]
|
||||
|
||||
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 10
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18.x
|
||||
cache: "pnpm"
|
||||
- name: Get package version
|
||||
id: package-version
|
||||
run: |
|
||||
VERSION=$(node -p "require('./package.json').version")
|
||||
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- name: Create Release Pull Request or Publish
|
||||
id: changesets
|
||||
uses: changesets/action@v1
|
||||
with:
|
||||
publish: pnpm run release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Send Discord notification
|
||||
if: steps.changesets.outputs.published == 'true'
|
||||
env:
|
||||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
# Get release URL using gh cli
|
||||
RELEASE_URL=$(gh release view "${{ steps.package-version.outputs.VERSION }}" --json url -q .url)
|
||||
|
||||
# Create a JSON file with the message
|
||||
cat > discord_payload.json << EOF
|
||||
{
|
||||
"content": "🎉 New release ${{ steps.package-version.outputs.VERSION }} is now available!\n\n📝 Changes:\n${{ steps.release-notes.outputs.NOTES }}\n\n🔗 Release: $RELEASE_URL"
|
||||
}
|
||||
EOF
|
||||
|
||||
# Send to Discord using curl
|
||||
curl -H "Content-Type: application/json" \
|
||||
-d @discord_payload.json \
|
||||
$DISCORD_WEBHOOK
|
||||
43
.github/workflows/release.yml
vendored
Normal file
43
.github/workflows/release.yml
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
name: Publish
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 10
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18.x
|
||||
cache: "pnpm"
|
||||
- name: Get package version
|
||||
id: package-version
|
||||
run: |
|
||||
VERSION=$(node -p "require('./package.json').version")
|
||||
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- name: Create Release Pull Request or Publish
|
||||
id: changesets
|
||||
uses: changesets/action@v1
|
||||
with:
|
||||
publish: pnpm run ci:publish
|
||||
version: pnpm run ci:version
|
||||
title: "Release: $VERSION"
|
||||
commit: "release: Release $VERSION"
|
||||
createGithubReleases: false # this is handled inside ci:publish script
|
||||
setupGitUser: false # this is handled inside ci:publish script
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
|
@ -13,7 +13,9 @@
|
|||
"docs:dev": "vitepress dev docs",
|
||||
"docs:build": "vitepress build docs",
|
||||
"docs:preview": "vitepress preview docs",
|
||||
"test": "jest"
|
||||
"test": "jest",
|
||||
"ci:publish": "./scripts/tag-and-publish.sh",
|
||||
"ci:version": "pnpm run version && changeset version"
|
||||
},
|
||||
"keywords": [
|
||||
"Obsidian",
|
||||
|
|
|
|||
28
scripts/tag-and-publish.sh
Executable file
28
scripts/tag-and-publish.sh
Executable file
|
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Get Release Notes
|
||||
version="${{ steps.package-version.outputs.VERSION }}"
|
||||
|
||||
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
|
||||
|
||||
cat release_notes.txt >> $NOTES
|
||||
|
||||
# Create and push tag
|
||||
git config user.name "GitHub Actions"
|
||||
git config user.email "actions@github.com"
|
||||
git tag -a "${{version}}" -m "Release version ${{version}}"
|
||||
git push origin "${{version}}"
|
||||
|
||||
# Create release
|
||||
gh release create "${{version}}" \
|
||||
--title="${{version}}" \
|
||||
--notes="${{ NOTES }}" \
|
||||
main.js manifest.json styles.css
|
||||
Loading…
Reference in a new issue