-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enforce version bump on PRs to main
- Loading branch information
Showing
15 changed files
with
134 additions
and
16 deletions.
There are no files selected for viewing
Empty file.
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,48 @@ | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
force-version-bump: | ||
runs-on: [digitalocean] | ||
steps: | ||
- name: Checkout backend | ||
uses: actions/checkout@v2 | ||
|
||
- name: Configure NodeJS | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
cache: "pnpm" | ||
registry-url: "https://npm.pkg.github.com" | ||
scope: "@chainflip-io" | ||
cache-dependency-path: "bouncer/pnpm-lock.yaml" | ||
- name: Download latest release binaries | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: release-perseverance.yml | ||
name: chainflip-backend-bin-ubuntu-22.04 | ||
github_token: ${{ secrets.CF_BACKEND_GITHUB_TOKEN }} | ||
path: latest-release-bins | ||
- name: Permissions for latest binaries | ||
run: | | ||
chmod +x ./latest-release-bins/chainflip-* | ||
- name: Version of the latest release | ||
run: | | ||
set -x | ||
echo $(pwd) | ||
RELEASE_VERSION=$(./latest-release-bins/chainflip-engine --version) | ||
echo $RELEASE_VERSION | ||
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV | ||
- name: Install node dependencies | ||
working-directory: bouncer | ||
run: pnpm install | ||
|
||
- name: Check the version of the branch is greater than the current release | ||
working-directory: bouncer | ||
run: | | ||
set -x | ||
echo ${{ env.RELEASE_VERSION }} | ||
./commands/read_workspace_tomls.ts ${{ github.workspace }} "${{ env.RELEASE_VERSION }}" | ||
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 @@ | ||
tmp |
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,2 +1,3 @@ | ||
pnpm-lock.yaml | ||
node_modules | ||
node_modules | ||
tmp |
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,57 @@ | ||
#!/usr/bin/env -S pnpm tsx | ||
|
||
import fs from 'fs'; | ||
import toml from '@iarna/toml'; | ||
import { compareSemVer } from '../shared/utils'; | ||
|
||
const projectRoot = process.argv[2]; | ||
const engineReleaseVersion = process.argv[3]; | ||
|
||
export function tomlVersion(cargoFilePath: string): Promise<string> { | ||
return new Promise((resolve, reject) => { | ||
fs.readFile(cargoFilePath, 'utf-8', (err, data) => { | ||
if (err) { | ||
reject(new Error('Error reading file: ' + err.message)); | ||
return; | ||
} | ||
|
||
try { | ||
const cargoToml = toml.parse(data); | ||
resolve(cargoToml.package.version); | ||
} catch (error) { | ||
reject(new Error('Error parsing TOML: ' + error.message)); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
const versionRegex = /\d+\.\d+\.\d+/; | ||
const releaseVersion = engineReleaseVersion.match(versionRegex)[0]; | ||
|
||
// Ensure all the versions are the same | ||
const engineTomlVersion = await tomlVersion(`${projectRoot}/engine/Cargo.toml`); | ||
const runtimeTomlVersion = await tomlVersion(`${projectRoot}/state-chain/runtime/Cargo.toml`); | ||
const nodeTomlVersion = await tomlVersion(`${projectRoot}/state-chain/node/Cargo.toml`); | ||
const cliTomlVersion = await tomlVersion(`${projectRoot}/api/bin/chainflip-cli/Cargo.toml`); | ||
const lpApiTomlVersion = await tomlVersion(`${projectRoot}/api/bin/chainflip-lp-api/Cargo.toml`); | ||
const brokerTomlVersion = await tomlVersion( | ||
`${projectRoot}/api/bin/chainflip-broker-api/Cargo.toml`, | ||
); | ||
|
||
if ( | ||
!( | ||
engineTomlVersion === runtimeTomlVersion && | ||
runtimeTomlVersion === nodeTomlVersion && | ||
nodeTomlVersion === cliTomlVersion && | ||
cliTomlVersion === lpApiTomlVersion && | ||
lpApiTomlVersion === brokerTomlVersion | ||
) | ||
) { | ||
throw Error('All versions should be the same'); | ||
} else if (compareSemVer(engineTomlVersion, releaseVersion) === 'greater') { | ||
console.log(`Version is correct. Your branch has a version greater than the current release.`); | ||
} else { | ||
throw Error( | ||
`Version is incorrect. The version of your branch (${engineTomlVersion}) should be greater than the current release (${releaseVersion}).)`, | ||
); | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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