Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add release workflow #805

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/shipjs-manual-prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Ship js Manual Prepare
on:
issue_comment:
types: [created]
jobs:
manual_prepare:
if: |
github.event_name == 'issue_comment' &&
(github.event.comment.author_association == 'member' || github.event.comment.author_association == 'owner') &&
startsWith(github.event.comment.body, '@shipjs prepare')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: master
- uses: actions/setup-node@v1
- run: |
if [ -f "yarn.lock" ]; then
yarn install
else
npm install
fi
- run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- run: npm run release -- --yes --no-browse
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_INCOMING_HOOK: ${{ secrets.SLACK_INCOMING_HOOK }}

create_done_comment:
if: success()
needs: manual_prepare
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "@${{github.actor}} `shipjs prepare` done"
})

create_fail_comment:
if: cancelled() || failure()
needs: manual_prepare
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "@${{github.actor}} `shipjs prepare` fail"
})
26 changes: 26 additions & 0 deletions .github/workflows/shipjs-schedule-prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Ship js Schedule Prepare
on:
schedule:
- cron: '0 9 * * 2'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can change the cron expression if there's any preferred time/date.
Currently it's every Tuesday 02:00 UTC.

jobs:
schedule_prepare:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: master
- uses: actions/setup-node@v1
- run: |
if [ -f "yarn.lock" ]; then
yarn install
else
npm install
fi
- run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- run: npm run release -- --yes --no-browse
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_INCOMING_HOOK: ${{ secrets.SLACK_INCOMING_HOOK }}
28 changes: 28 additions & 0 deletions .github/workflows/shipjs-trigger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Ship js trigger
on:
pull_request:
types:
- closed
jobs:
build:
name: Release
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'releases/v')
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: master
- uses: actions/setup-node@v1
with:
registry-url: 'https://registry.npmjs.org'
- run: |
if [ -f "yarn.lock" ]; then
yarn install
else
npm install
fi
- run: npx shipjs trigger
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"reflect-metadata": "^0.1.13",
"rollup": "^2.55.0",
"rollup-plugin-typescript2": "^0.30.0",
"shipjs": "0.23.3",
"ts-jest": "25.3.1",
"typescript": "^4.3.5",
"vitepress": "^0.15.6",
Expand Down Expand Up @@ -67,7 +68,8 @@
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"vue-tsc": "vue-tsc --noEmit -p tsconfig.volar.json",
"prepublishOnly": "yarn build"
"prepublishOnly": "yarn build",
"release": "shipjs prepare"
},
"husky": {
"hooks": {
Expand Down
11 changes: 11 additions & 0 deletions ship.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
publishCommand: ({ defaultCommand, tag }) =>
`${defaultCommand} --access public --tag ${tag}`,
Comment on lines +2 to +3
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will run a command like npm publish --access public --tag latest.

shouldPrepare: ({ releaseType, commitNumbersPerType }) => {
const { fix = 0 } = commitNumbersPerType
if (releaseType === 'patch' && fix === 0) {
return false
}
return true
}
Comment on lines +4 to +10
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's going to be a patch release, but doesn't include "fix" commits, then it will skip the release. Think about having only "chore" commits. You probably don't want to release it.

This is especially useful when you have scheduled releases.

}
Loading