generated from siyuan-note/plugin-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
89 additions
and
39 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,97 @@ | ||
name: Release Workflow | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
name: release-please | ||
jobs: | ||
release: | ||
release-please: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
|
||
- name: Install Dependencies and Build | ||
id: build | ||
run: | | ||
npm install -g pnpm && pnpm install && pnpm run build | ||
echo "::set-output name=zip_path::$(pwd)/package.zip" | ||
- name: Get Current Version | ||
id: version | ||
run: echo "::set-output name=version::$(node -p "require('./package.json').version")" | ||
|
||
- name: Check for Existing Release | ||
id: check_release | ||
run: | | ||
current_version="${{ steps.version.outputs.version }}" | ||
if git rev-parse -q --verify "refs/tags/v$current_version"; then | ||
echo "Release $current_version already exists. Nothing to do." | ||
exit 0 | ||
fi | ||
commit_message=$(git log -1 --pretty=%B) | ||
release_title="v$current_version" | ||
echo "Creating release $release_title" | ||
release_id=$(curl -s -X POST -H "Authorization: Bearer ${{ secrets.GH_TOKEN }}" -d "{\"tag_name\": \"$release_title\", \"name\": \"$release_title\", \"body\": \"$commit_message\"}" "https://api.github.com/repos/${{ github.repository }}/releases" | jq -r '.id') | ||
zip_path="${{ steps.build.outputs.zip_path }}" | ||
echo "Uploading binary to release $release_id" | ||
curl -s -X POST -H "Authorization: Bearer ${{ secrets.GH_TOKEN }}" -H "Content-Type: application/zip" --data-binary "@$zip_path" "https://uploads.github.com/repos/${{ github.repository }}/releases/$release_id/assets?name=package.zip" | ||
# Create release | ||
- name: Create release | ||
uses: google-github-actions/release-please-action@v3 | ||
id: release | ||
with: | ||
release-type: node | ||
package-name: release-please-action | ||
## branch to open pull release PR against (detected by default) | ||
default-branch: main | ||
## Should breaking changes before 1.0.0 produce minor bumps? Default false | ||
# bump-minor-pre-major: true | ||
## Should feat changes before 1.0.0 produce patch bumps instead of minor bumps? Default false | ||
# bump-patch-for-minor-pre-major: true | ||
## If set, create releases that are pre-major or pre-release version marked as pre-release on GitHub. Defaults false | ||
prerelease: false | ||
## header used within the release PR body, defaults to using :robot: I have created a release *beep* *boop* | ||
pull-request-header: ':robot: A new release will be created' | ||
## A JSON formatted String containing to override the outputted changelog sections | ||
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"refactor","section":"Code Refactoring","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false},{"type":"perf","section":"Performance Improvements","hidden":false}]' | ||
|
||
# Checkout | ||
- name: Checkout | ||
if: ${{ steps.release.outputs.release_created }} | ||
uses: actions/checkout@v3 | ||
|
||
# Install Node.js | ||
- name: Install Node.js | ||
if: ${{ steps.release.outputs.release_created }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
registry-url: 'https://registry.npmjs.org' | ||
|
||
# Install pnpm | ||
- name: Install pnpm | ||
if: ${{ steps.release.outputs.release_created }} | ||
uses: pnpm/action-setup@v2 | ||
id: pnpm-install | ||
with: | ||
version: 8 | ||
run_install: false | ||
|
||
# Get pnpm store directory | ||
- name: Get pnpm store directory | ||
if: ${{ steps.release.outputs.release_created }} | ||
id: pnpm-cache | ||
shell: bash | ||
run: | | ||
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | ||
# Setup pnpm cache | ||
- name: Setup pnpm cache | ||
if: ${{ steps.release.outputs.release_created }} | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | ||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store- | ||
# Install dependencies | ||
- name: Install dependencies | ||
if: ${{ steps.release.outputs.release_created }} | ||
run: pnpm install | ||
|
||
# Prepare new version | ||
# https://github.com/google-github-actions/release-please-action#outputs | ||
- name: Prepare new version | ||
if: ${{ steps.release.outputs.release_created }} | ||
run: | | ||
pnpm prepareRelease | ||
# Build for production and Archive package | ||
- name: Build for production | ||
if: ${{ steps.release.outputs.release_created }} | ||
run: pnpm package | ||
|
||
# Upload package to release | ||
# https://github.com/philips-labs/terraform-aws-github-runner/blob/main/.github/workflows/release.yml#L46 | ||
- name: Upload package.zip to the release | ||
if: ${{ steps.release.outputs.releases_created }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
run: | | ||
for f in $(find ./build -name '*.zip'); do | ||
gh release upload ${{ steps.release.outputs.tag_name }} $f | ||
done |