-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added release.mjs script and release.yml gh action (#75)
- Loading branch information
Showing
3 changed files
with
97 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Very important! | ||
# Make sure that the github token has read AND WRITE access on github. | ||
# 1. hit https://github.com/seatsio/[REPO]/settings/actions | ||
# 2. under "Workflow permissions", make sure "Read and write permissions" is checked instead of the (default?) read only. | ||
# | ||
|
||
name: Release | ||
run-name: Release ${{ github.repository }} | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
versionToBump: | ||
description: 'The version to bump. Major for incompatible API changes, minor for adding BC features' | ||
required: true | ||
type: choice | ||
options: | ||
- minor | ||
- major | ||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: fregante/setup-git-user@v2 | ||
- id: install-zx | ||
run: npm i -g zx | ||
- id: install-semver-tool | ||
run: | | ||
wget -O /usr/local/bin/semver https://raw.githubusercontent.com/fsaintjacques/semver-tool/master/src/semver | ||
chmod +x /usr/local/bin/semver | ||
- run: zx ./release.mjs -v $VERSION_TO_BUMP | ||
env: | ||
VERSION_TO_BUMP: ${{ inputs.versionToBump }} | ||
GH_TOKEN: ${{ github.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/env zx | ||
|
||
/* | ||
* Script to release the seats.io java lib. | ||
* - changes the version number in README.md | ||
* - changes the version number in build.gradle | ||
* - creates the release in Gihub (using gh cli) | ||
* | ||
* | ||
* Prerequisites: | ||
* - zx installed (https://github.com/google/zx) | ||
* - gh cli installed (https://cli.github.com/) | ||
* - semver cli installed (https://github.com/fsaintjacques/semver-tool) | ||
* | ||
* Usage: | ||
* zx ./release.mjs -v major/minor -n "release notes" | ||
* */ | ||
|
||
// don't output the commands themselves | ||
$.verbose = false | ||
|
||
const versionToBump = getVersionToBump() | ||
const latestVersion = await fetchLatestReleasedVersionNumber() | ||
|
||
await pullLastVersion().then(release) | ||
|
||
function getVersionToBump() { | ||
if (!argv.v || !(argv.v === 'minor' || argv.v === 'major')) { | ||
throw new Error ("Please specify -v major/minor") | ||
} | ||
return argv.v | ||
} | ||
|
||
function removeLeadingV(tagName) { | ||
if (tagName.startsWith('v')) { | ||
return tagName.substring(1) | ||
} | ||
return tagName | ||
} | ||
|
||
async function fetchLatestReleasedVersionNumber() { | ||
let result = await $`gh release view --json tagName` | ||
let tagName = JSON.parse(result).tagName | ||
return removeLeadingV(tagName) | ||
} | ||
|
||
async function determineNextVersionNumber(previous) { | ||
return (await $`semver bump ${versionToBump} ${previous}`).stdout.trim() | ||
} | ||
|
||
async function pullLastVersion() { | ||
await $`git checkout master` | ||
await $`git pull origin master` | ||
} | ||
|
||
async function release() { | ||
const nextVersion = await determineNextVersionNumber(latestVersion) | ||
const newTag = 'v' + nextVersion | ||
return await $`gh release create ${newTag} --generate-notes`.catch(error => { | ||
console.error('something went wrong while creating the release. Please revert the version change!') | ||
throw error | ||
}) | ||
} |
This file was deleted.
Oops, something went wrong.