Skip to content

Commit

Permalink
feat(actions): ♻️ rebuild CI build system (#1)
Browse files Browse the repository at this point in the history
The `release` workflow will run with the follow steps by trigger manually:
1. Set up job and checkout code for all history with tags.
2. Bump version of `package.json` and write change log with `standard-version`.
3. Pretty the format of `CHANGELOG.md` and push the commit.
4. Follow the [official tutorials](https://code.visualstudio.com/api/working-with-extensions/continuous-integration#github-actions-automated-publishing) to publish extension.
5. Build the `.vsix`.
6. Get the release note from the formated `CHANGELOG.md` by using `mindsers/changelog-reader-action`.
7. Create release.
8. Upload release asset.

Other changes:
1. add `CHANGELOG.md` into `.prettierignore`.
2. add the script `deploy` for publish.
3. delete the script `version`.
4. delete the script `release`.
5. use the cmd of `sed 's/^### \[/## [/' -i CHANGELOG.md` to change the changelog content, because it will make content to fit the markdown rules.
6. use the cmd of `yarn prettier --write CHANGELOG.md --prose-wrap never --ignore-path ./gitignore
` to pretty the format of `CHANGELOG.md`, and it will make content to fill correcttly with the release body.

Close #59
  • Loading branch information
yi-Xu-0100 authored Mar 11, 2021
1 parent caa8f5c commit ca3094c
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 154 deletions.
70 changes: 38 additions & 32 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
name: release

on:
push:
branches:
- master
paths:
- CHANGELOG.md
workflow_dispatch:

jobs:
run:
Expand All @@ -14,8 +10,19 @@ jobs:
steps:
- name: Checkout code
uses: actions/[email protected]
with:
fetch-depth: 0

- name: Setup package
run: yarn install

- name: Get version from package
- name: Bump version
run: |
yarn standard-version --skip.commit --skip.tag
sed 's/^### \[/## [/' -i CHANGELOG.md
yarn prettier --write CHANGELOG.md --prose-wrap never --ignore-path ./gitignore
- name: Get version from package.json
uses: actions/[email protected]
id: version
with:
Expand All @@ -24,29 +31,29 @@ jobs:
const version = require(`${process.env.GITHUB_WORKSPACE}/package.json`).version;
core.setOutput('repo', context.repo.repo);
core.setOutput('version', version);
const time = new Date(Date.now()).toISOString().slice(0,10);
const titleLink = version.replace(/\./g,'') + '-' + time;
core.setOutput('titleLink', titleLink);
try {
var latestRelease = await github.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo
});
const latestTag = latestRelease.data.tag_name;
core.setOutput('commitLink', `compare/${latestTag}...v${version}`);
} catch (error) {
if (error.message === 'Not Found') {
core.setOutput('commitLink', `commits/v${version}`);
} else {
core.setFailed(error.message);
}
}
return true;
- name: Generate Package
- name: Push commit
run: |
yarn install
yarn run build
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 push https://x-access-token:${{secrets.GITHUB_TOKEN}}@github.com/${{github.GITHUB_REPOSITORY}}.git
- name: Publish package
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
run: yarn run deploy

- name: Build release asset
run: yarn run build

- name: Get Changelog Entry
id: changelog_reader
uses: mindsers/[email protected]
with:
version: ${{steps.version.outputs.version}}
path: ./CHANGELOG.md

- name: Create release
id: create_release
Expand All @@ -56,11 +63,10 @@ jobs:
with:
tag_name: v${{steps.version.outputs.version}}
release_name: Release v${{steps.version.outputs.version}}
body: |
* Changelogs:
<https://github.com/${{github.repository}}/blob/master/CHANGELOG.md#${{steps.version.outputs.titleLink}}>
* Commits:
<https://github.com/${{github.repository}}/${{steps.version.outputs.commitLink}}>
body: ${{ steps.changelog_reader.outputs.changes }}
prerelease:
${{ steps.changelog_reader.outputs.status == 'prereleased' }}
draft: ${{ steps.changelog_reader.outputs.status == 'unreleased' }}

- name: Upload release asset
uses: actions/[email protected]
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CHANGELOG.md
Loading

0 comments on commit ca3094c

Please sign in to comment.