-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(actions): ✨ add prepare-release workflow
- Loading branch information
1 parent
220d6c3
commit 70080a4
Showing
4 changed files
with
130 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,107 @@ | ||
name: 'prepare release' | ||
on: | ||
workflow_run: | ||
workflows: ['release'] | ||
branches: [main] | ||
types: | ||
- completed | ||
push: | ||
branches: | ||
- main | ||
|
||
env: | ||
BASE_BRANCH: 'main' | ||
HEAD_BRANCH: 'prepare-release' | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
jobs: | ||
build: | ||
name: Prepare release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup nodejs | ||
uses: actions/[email protected] | ||
with: | ||
node-version: 12 | ||
|
||
- uses: actions/[email protected] | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-node- | ||
- name: Bump version | ||
run: | | ||
npx standard-version --skip.commit --skip.tag | ||
sed 's/^### \[/## [/' -i CHANGELOG.md | ||
npx prettier --write 'CHANGELOG.md' --prose-wrap never --ignore-path './gitignore' | ||
- name: Get version from package.json | ||
uses: actions/[email protected] | ||
id: version | ||
with: | ||
result-encoding: string | ||
script: | | ||
const version = require(`${process.env.GITHUB_WORKSPACE}/package.json`).version; | ||
core.setOutput('repo', context.repo.repo); | ||
core.setOutput('version', version); | ||
core.setOutput('title', 'chore(release): :bookmark: release v' + version); | ||
- name: Create commit | ||
run: | | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
git add . | ||
git commit -m 'chore(release): :bookmark: release v${{steps.version.outputs.version}}' | ||
git branch -D '${{ env.HEAD_BRANCH }}' 2>&1 | sed 's/error/warning/' | ||
git checkout -b '${{ env.HEAD_BRANCH }}' | ||
git remote set-url origin 'https://x-access-token:${{secrets.GITHUB_TOKEN}}@github.com/${{github.repository}}.git' | ||
git push -f -u origin '${{ env.HEAD_BRANCH }}' | ||
- name: Get Changelog Entry | ||
id: changelog_reader | ||
uses: mindsers/[email protected] | ||
with: | ||
version: ${{steps.version.outputs.version}} | ||
path: ./CHANGELOG.md | ||
|
||
- name: Get Changelog | ||
uses: actions/[email protected] | ||
id: changelog | ||
env: | ||
CHANGELOG: ${{ steps.changelog_reader.outputs.changes }} | ||
with: | ||
script: return process.env.CHANGELOG; | ||
|
||
- name: Create pull request | ||
run: | | ||
curl \ | ||
-X POST \ | ||
-H 'authorization: token ${{secrets.GITHUB_TOKEN}}' \ | ||
-H 'Accept: application/vnd.github.v3+json' \ | ||
'https://api.github.com/repos/${{github.repository}}/pulls' \ | ||
-d '{"head":"${{ env.HEAD_BRANCH }}","base":"${{ env.BASE_BRANCH }}","title":"${{steps.version.outputs.title}}","body":${{steps.CHANGELOG.outputs.result}},"maintainer_can_modify":true}' | ||
- name: Find pull request | ||
uses: juliangruber/[email protected] | ||
id: find-pull-request | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
branch: ${{ env.HEAD_BRANCH }} | ||
|
||
- name: Update pull request | ||
env: | ||
NUMBER: ${{ steps.find-pull-request.outputs.number }} | ||
run: | | ||
curl \ | ||
-X PATCH \ | ||
-H 'authorization: token ${{secrets.GITHUB_TOKEN}}' \ | ||
-H 'Accept: application/vnd.github.v3+json' \ | ||
'https://api.github.com/repos/${{github.repository}}/pulls/${{ env.NUMBER }}' \ | ||
-d '{"base":"${{ env.BASE_BRANCH }}","title":"${{steps.version.outputs.title}}","body":${{steps.CHANGELOG.outputs.result}}}' |
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,4 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npx --no-install lint-staged && npm run lint-check | ||
npx --no-install lint-staged |
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,22 +1,42 @@ | ||
// .prettierrc.js | ||
module.exports = { | ||
// max 120 characters per line | ||
printWidth: 120, | ||
// use 2 spaces for indentation | ||
tabWidth: 2, | ||
// use spaces instead of indentations | ||
useTabs: false, | ||
// semicolon at the end of the line | ||
semi: true, | ||
// use single quotes | ||
singleQuote: true, | ||
// object's key is quoted only when necessary | ||
quoteProps: 'as-needed', | ||
// use double quotes instead of single quotes in jsx | ||
jsxSingleQuote: false, | ||
// no comma at the end | ||
trailingComma: 'all', | ||
// spaces are required at the beginning and end of the braces | ||
bracketSpacing: true, | ||
// end tag of jsx need to wrap | ||
jsxBracketSameLine: false, | ||
// brackets are required for arrow function parameter, even when there is only one parameter | ||
arrowParens: 'always', | ||
// format the entire contents of the file | ||
rangeStart: 0, | ||
rangeEnd: Infinity, | ||
// no need to write the beginning @prettier of the file | ||
requirePragma: false, | ||
// No need to automatically insert @prettier at the beginning of the file | ||
insertPragma: false, | ||
// use default break criteria | ||
proseWrap: 'preserve', | ||
// decide whether to break the html according to the display style | ||
htmlWhitespaceSensitivity: 'css', | ||
// vue files script and style tags indentation | ||
vueIndentScriptAndStyle: false, | ||
// lf for newline | ||
endOfLine: 'lf', | ||
// formats quoted code embedded | ||
embeddedLanguageFormatting: 'auto', | ||
}; | ||
}; |
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