-
-
Notifications
You must be signed in to change notification settings - Fork 756
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removes manual steps in creating a version (#3330)
- Loading branch information
Showing
3 changed files
with
46 additions
and
16 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 |
---|---|---|
@@ -1,7 +1,12 @@ | ||
name: Release | ||
|
||
on: | ||
workflow_dispatch | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: Version to change to. | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
release: | ||
|
@@ -22,27 +27,29 @@ jobs: | |
with: | ||
node-version-file: '.nvmrc' | ||
|
||
- name: Get version | ||
id: package-version | ||
uses: martinbeentjes/[email protected] | ||
|
||
# - name: Check tag does not exist yet | ||
# run: if git rev-list v${{ steps.package-version.outputs.current-version }}; then echo "Tag already exists. Aborting the release process."; exit 1; fi | ||
|
||
- name: Bump version | ||
run: | | ||
npm version --commit-hooks false --git-tag-version false ${{ inputs.version }} | ||
./build/bump-version-changelog.js | ||
git commit -m "Bump version to ${{ inputs.version }}" | ||
- name: Push changes | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Tag commit and push | ||
uses: mathieudutour/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
custom_tag: ${{ steps.package-version.outputs.current-version }} | ||
custom_tag: ${{ inputs.version }} | ||
|
||
- name: Install | ||
run: npm ci | ||
|
||
- name: Prepare release | ||
id: prepare_release | ||
run: | | ||
echo "version_tag=v${{ steps.package-version.outputs.current-version }}" >> $GITHUB_OUTPUT | ||
RELEASE_TYPE=$(node -e "console.log(require('semver').prerelease('${{ steps.package-version.outputs.current-version }}') ? 'prerelease' : 'regular')") | ||
echo "version_tag=v${{ inputs.version }}" >> $GITHUB_OUTPUT | ||
RELEASE_TYPE=$(node -e "console.log(require('semver').prerelease('${{ inputs.version }}') ? 'prerelease' : 'regular')") | ||
echo "release_type=$RELEASE_TYPE" >> $GITHUB_OUTPUT | ||
- name: Build | ||
|
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,26 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* This script updates the changelog.md file with the version given in the arguments | ||
* It replaces ## main with ## <version> | ||
* Removes _...Add new stuff here..._ | ||
* And adds on top a ## main with add stuff here. | ||
*/ | ||
|
||
import * as fs from 'fs'; | ||
|
||
const changelogPath = 'CHANGELOG.md'; | ||
let changelog = fs.readFileSync(changelogPath, 'utf8'); | ||
changelog = changelog.replace('## main', `## ${process.argv[2]}`); | ||
changelog = changelog.replaceAll('- _...Add new stuff here..._\n', ''); | ||
changelog = `## main | ||
### ✨ Features and improvements | ||
- _...Add new stuff here..._ | ||
### 🐞 Bug fixes | ||
- _...Add new stuff here..._ | ||
` + changelog; | ||
|
||
fs.writeFileSync(changelogPath, changelog, 'utf8'); |
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