Skip to content

Commit

Permalink
Use zx and semver NPM packages in release script (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
mortendevold authored Jul 19, 2024
1 parent c7d0beb commit f7bb753
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@ jobs:
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
- name: Install dependencies
run: yarn add -D -E [email protected] [email protected]
- name: Run release script
run: yarn zx ./release.mjs -v $VERSION_TO_BUMP
env:
VERSION_TO_BUMP: ${{ inputs.versionToBump }}
GH_TOKEN: ${{ github.token }}
Expand Down
8 changes: 4 additions & 4 deletions release.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env zx

/*
* Script to release the seats.io java lib.
* Script to release the seats.io ios lib.
* - changes the version number in README.md
* - changes the version number in build.gradle
* - creates the release in Gihub (using gh cli)
Expand All @@ -10,15 +10,15 @@
* 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"
* yarn zx ./release.mjs -v major/minor -n "release notes"
* */

// don't output the commands themselves
$.verbose = false

const semver = require('semver')
const versionToBump = getVersionToBump()
const latestVersion = await fetchLatestReleasedVersionNumber()
const nextVersion = await determineNextVersionNumber(latestVersion)
Expand All @@ -41,7 +41,7 @@ async function fetchLatestReleasedVersionNumber() {
}

async function determineNextVersionNumber(previous) {
return (await $`semver bump ${versionToBump} ${previous}`).stdout.trim()
return semver.inc(previous, versionToBump)
}

async function bumpVersionInFiles() {
Expand Down

0 comments on commit f7bb753

Please sign in to comment.