Skip to content

Commit

Permalink
chore: 优化构建流程
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed May 12, 2023
1 parent c5622f3 commit f4aeea1
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 2 deletions.
98 changes: 98 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
on:
push:
branches:
- main
- dev

name: release-please
jobs:
release-please:
runs-on: ubuntu-latest
steps:
# 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: dev
## 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@v3
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 syncVersion ${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }}
# 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
3 changes: 2 additions & 1 deletion apps/publisher-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-check --tsconfig ./tsconfig.json"
"check": "svelte-check --tsconfig ./tsconfig.json",
"syncVersion": "echo 'syncVersion in app'"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^2.0.3",
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"dockerBuild": "turbo run dockerBuild",
"vercelBuild": "turbo run vercelBuild",
"siyuanBuild": "turbo run siyuanBuild",
"syncVersion": "turbo run syncVersion",
"package": "echo 'package in root'",
"test": "turbo run test",
"start": "turbo run start",
"doc": "turbo run doc",
Expand Down
3 changes: 2 additions & 1 deletion plugins/publisher-main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"dev": "vite",
"build": "vite build",
"start": "vite preview",
"test": "vitest --watch"
"test": "vitest --watch",
"syncVersion": "echo 'syncVersion in main'"
},
"devDependencies": {
"@terwer/eslint-config-custom": "latest",
Expand Down
6 changes: 6 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
"nodeBuild": {
"cache": false
},
"package": {
"cache": false
},
"syncVersion": {
"cache": false
},
"test": {
"dependsOn": ["^build"]
},
Expand Down

0 comments on commit f4aeea1

Please sign in to comment.