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

feat(actions): ♻️ rebuild CI build system #61

Closed
wants to merge 14 commits into from
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
Copy link
Owner

Choose a reason for hiding this comment

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

Better to have a git tag here. Previously --skip.tag was used in standard-version.


- 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
yi-Xu-0100 marked this conversation as resolved.
Show resolved Hide resolved
Loading