mirror of
https://github.com/h-sphere/sql-seal-charts.git
synced 2026-07-22 05:37:34 +00:00
chore: adding changeset based publish
This commit is contained in:
parent
76a634cfc8
commit
447548cece
2 changed files with 41 additions and 88 deletions
41
.github/workflows/release.yml
vendored
Normal file
41
.github/workflows/release.yml
vendored
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
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 current version
|
||||
id: get-version
|
||||
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- run: pnpm build
|
||||
- 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] ${{ steps.changesets.outputs.version || 'Next' }}"
|
||||
commit: "release: Release ${{ steps.changesets.outputs.version || 'Next' }}"
|
||||
createGithubReleases: false # this is handled inside ci:publish script
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
88
.github/workflows/tag-and-publish.yml
vendored
88
.github/workflows/tag-and-publish.yml
vendored
|
|
@ -1,88 +0,0 @@
|
|||
name: Check Version and Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'package.json'
|
||||
|
||||
jobs:
|
||||
check-and-release:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "18.x"
|
||||
|
||||
- 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: Install packages
|
||||
if: steps.check-tag.outputs.EXISTS == 'false'
|
||||
run: npm install
|
||||
|
||||
- name: Build plugin
|
||||
if: steps.check-tag.outputs.EXISTS == 'false'
|
||||
run: |
|
||||
npm run build
|
||||
|
||||
- name: Extract release notes
|
||||
if: steps.check-tag.outputs.EXISTS == 'false'
|
||||
id: release-notes
|
||||
run: |
|
||||
version="${{ steps.package-version.outputs.VERSION }}"
|
||||
|
||||
# Use awk to extract the section for the current 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
|
||||
|
||||
# Escape multiline output for GitHub Actions
|
||||
echo "NOTES<<EOF" >> $GITHUB_OUTPUT
|
||||
cat release_notes.txt >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Create tag and release
|
||||
if: steps.check-tag.outputs.EXISTS == 'false'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
# Create and push tag
|
||||
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 }}"
|
||||
|
||||
# Create release
|
||||
gh release create "${{ steps.package-version.outputs.VERSION }}" \
|
||||
--title="${{ steps.package-version.outputs.VERSION }}" \
|
||||
--notes="${{ steps.release-notes.outputs.NOTES }}" \
|
||||
main.js manifest.json styles.css
|
||||
Loading…
Reference in a new issue