Skip to content

Commit

Permalink
feat: add workflow action about auto publish #TINFR-632
Browse files Browse the repository at this point in the history
  • Loading branch information
luxiaobei committed Nov 25, 2024
1 parent f5ada30 commit 3425136
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 3 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Publish

on:
pull_request:
types:
- opened
- reopened
pull_request_review:
types:
- submitted
check_suite:
types:
- completed
status: {}

jobs:
autoApprove:
if: startsWith(github.head_ref, 'release-auto-')
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: hmarr/auto-approve-action@v4
with:
review-message: 'Auto approve sync PRs to auto merge them'
publish:
if: startsWith(github.head_ref, 'release-auto-')
needs: [autoApprove]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: yarn install
- name: Publish
if: startsWith(github.head_ref, 'release-auto-v')
run: |
git config user.name github-actions
git config user.email github-actions@github.com
yarn pub
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish-next
if: startsWith(github.head_ref, 'release-auto-next-v')
run: |
git config user.name github-actions
git config user.email github-actions@github.com
yarn pub-next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Read package.json
id: read-version
uses: notiz-dev/github-action-json-property@release
with:
path: 'package.json'
prop_path: 'version'
- name: send message to webhook
uses: joelwmale/webhook-action@master
with:
url: 'https://hook-rc.pingcode.com/api/flow/w/http/357bdd4f00f34bfab2f878ad3b9e8b48'
body: '{ "version": "${{ steps.read-version.outputs.prop }}", "name": "tethys-pro" }'
autoMerge:
if: startsWith(github.head_ref, 'release-auto-')
needs: [publish]
runs-on: ubuntu-latest
steps:
- id: autoMerge
name: autoMerge
uses: 'pascalgn/automerge-action@v0.15.5'
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
MERGE_LABELS: ''
MERGE_FORKS: 'false'
MERGE_RETRIES: '20'
MERGE_RETRY_SLEEP: '60000'
5 changes: 3 additions & 2 deletions .wpmrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
allowBranch: ['master', 'release-*'],
allowBranch: ['master', 'release-*', 'release-auto-*'],
bumpFiles: [
'package.json',
'./packages/auth/package.json',
Expand All @@ -10,7 +10,8 @@ module.exports = {
}
],
skip: {
changelog: true
changelog: true,
confirm: true
},
commitAll: true,
hooks: {
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
"build": "npm-run-all build:libs sync-styles",
"build:docs": "docgeni build",
"build:libs": "ts-node --project ./scripts/tsconfig.json ./scripts/build-packages.ts",
"release": "wpm release",
"release-manual": "wpm release",
"release": "wpm release --release-branch-format release-auto-v{{version}}",
"release-next-manual": "wpm release --release-branch-format release-next-v{{version}}",
"release-next": "wpm release --release-branch-format release-auto-next-v{{version}}",
"pub-only": "ts-node --project ./scripts/tsconfig.json ./scripts/npm-publish.ts",
"pub-next-only": "ts-node --project ./scripts/tsconfig.json ./scripts/npm-publish.ts --next",
"pub": "wpm publish && yarn pub-only",
Expand Down

0 comments on commit 3425136

Please sign in to comment.