-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
173 additions
and
1 deletion.
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,53 @@ | ||
name: Create New Version | ||
run-name: Creating new ${{ github.event.inputs.version }} ${{ github.event.inputs.channel }} version | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: Version | ||
type: choice | ||
options: | ||
- major | ||
- minor | ||
- patch | ||
default: minor | ||
channel: | ||
description: Channel | ||
type: choice | ||
options: | ||
- release | ||
- beta | ||
default: release | ||
|
||
env: | ||
CI: true | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
version: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.BCC_BOT_ACCESS_TOKEN }} | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
registry-url: 'https://registry.npmjs.org' | ||
|
||
- name: Set commit author to bcc-bot | ||
run: | | ||
git config --global user.name "bcc-bot" | ||
git config --global user.email "[email protected]" | ||
- name: Version new ${{ github.event.inputs.version }} version | ||
run: npm run create-version -- ${{ github.event.inputs.version }} ${{ github.event.inputs.channel }} | ||
|
||
- name: Push | ||
run: git push --follow-tags |
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,38 @@ | ||
name: "Prepare release" | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
env: | ||
CI: true | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
permissions: | ||
contents: write # for softprops/action-gh-release to create GitHub release | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- run: git fetch --tags -f | ||
|
||
- name: Resolve version | ||
id: vars | ||
run: | | ||
echo "TAG_NAME=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV | ||
- name: Create Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
draft: true | ||
name: "schema-sync ${{ env.TAG_NAME }}" | ||
tag_name: ${{ env.TAG_NAME }} | ||
generate_release_notes: true |
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,41 @@ | ||
name: Release | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
permissions: | ||
contents: read | ||
|
||
env: | ||
CI: true | ||
|
||
jobs: | ||
build: | ||
if: contains(github.event.release.name, 'schema-sync') | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
registry-url: 'https://registry.npmjs.org' | ||
cache: 'npm' | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Build Extension | ||
run: npm build | ||
|
||
- name: Set release channel | ||
run: | | ||
echo "RELEASE_CHANNEL=$(npm run release-channel --silent)" >> $GITHUB_ENV | ||
- name: Publish Extension | ||
run: npm publish --tag ${{ env.RELEASE_CHANNEL }} | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
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
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,39 @@ | ||
const { exec } = require("node:child_process"); | ||
const { exit } = require("node:process"); | ||
const currentVersion = require("../package.json").version; | ||
|
||
let increment = process.argv[2]; | ||
let channel = process.argv[3] ?? "release"; | ||
|
||
if (!increment) { | ||
console.log("No version increment given! Exiting..."); | ||
exit(); | ||
} | ||
|
||
let update = `pre${increment}`; | ||
if (currentVersion.includes(channel)) { | ||
update = "prerelease"; | ||
} | ||
|
||
const versionParts = /(\d+\.\d+\.\d+)-(.*)\.\d+/g.exec(currentVersion); | ||
|
||
// If there is a prerelease tag in the name but the channel is for public release, | ||
// just strip the prerelease tag from the name | ||
if (versionParts && channel == "release") { | ||
increment = versionParts[1]; | ||
} | ||
|
||
const command = `npm version ${ | ||
channel == "release" ? increment : `${update} --preid ${channel}` | ||
} --no-git-tag-version`; | ||
|
||
// Version package | ||
exec(command, (error, newVersion) => { | ||
if (error) console.error(error); | ||
const tagVersion = newVersion.replace("\n", ""); | ||
exec( | ||
`git add . && git commit -m "schema-sync ${tagVersion}" && git tag -am ${tagVersion} "${tagVersion}"` | ||
); | ||
|
||
console.log(`Tagged new version ${tagVersion}`) | ||
}); |