Skip to content

Commit

Permalink
chore: optimize publish workflow (ckb-js#425)
Browse files Browse the repository at this point in the history
* chore: optimize publish workflow

* feat: workflow support generate-changelog

* fix: fix prerelease
  • Loading branch information
PainterPuppets authored Sep 26, 2022
1 parent 009577a commit 064c601
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,29 @@ jobs:
github_repo: ${{ github.repository }}
git_commit_sha: ${{ github.sha }}
git_tag_prefix: "v"

- name: Run generate-changelog
id: generate-changelog
uses: autowarefoundation/autoware-github-actions/generate-changelog@v1

- name: Show result
run: |
echo "$CHANGELOG"
env:
CHANGELOG: ${{ steps.generate-changelog.outputs.changelog }}

- name: Create Release
id: create_release
if: steps.tag_check.outputs.exists_tag == 'false'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_BODY: ${{ github.event.commits[0].message }}
with:
tag_name: v${{ env.CURRENT_VERSION }}
# Copy Pull Request's tile and body to Release Note
body: ${{ env.CHANGELOG }}
release_name: ${{ env.CURRENT_VERSION }}
body: |
${{ env.RELEASE_BODY }}
draft: false
prerelease: steps.tag_check.prerelease_check.prerelease == 'true'
prerelease: ${{ steps.tag_check.prerelease_check.prerelease }}

- name: Publish
if: steps.tag_check.outputs.exists_tag == 'false'
Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@
"versionup:minor": "lerna version minor --conventional-commits --no-git-tag-version",
"versionup:major": "lerna version major --conventional-commits --no-git-tag-version",
"versionup:prerelease": "lerna version prerelease --conventional-commits --no-git-tag-version --conventional-prerelease --force-publish",
"postversionup": "npm run commit-version",
"postversionup:patch": "npm run commit-version",
"postversionup:minor": "npm run commit-version",
"postversionup:major": "npm run commit-version",
"commit-version": "git add . && git commit -m \"chore: publish `node -p 'require(\"./lerna.json\").version'`\""
"postversionup": "npm run create-publish-branch",
"postversionup:patch": "npm run create-publish-branch",
"postversionup:minor": "npm run create-publish-branch",
"postversionup:major": "npm run create-publish-branch",
"postversionup:prerelease": "npm run create-publish-branch",
"commit-version": "git add . && git commit -m \"chore: publish `node -p 'require(\"./lerna.json\").version'`\"",
"create-publish-branch": "node ./scripts/create_publish_branch.js"
},
"husky": {
"hooks": {
Expand Down
12 changes: 12 additions & 0 deletions scripts/create_publish_branch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const shell = require("shelljs");
const lernaJson = require("../lerna.json");

let branch = 'v' + lernaJson.version;
if (/alpha/.test(lernaJson.version)) {
branch = 'next/' + branch;
}

shell.exec(`git checkout -b ${branch}`)
shell.exec(`git add . && git commit -m \"chore: publish ${lernaJson.version}\"`)


0 comments on commit 064c601

Please sign in to comment.