generated from Ed-Fi-Exchange-OSS/Template-for-GitHub
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert last commit - does not work with branch protection (#317)
- Loading branch information
1 parent
b752c4d
commit be106a6
Showing
9 changed files
with
6,205 additions
and
37 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 |
---|---|---|
|
@@ -14,56 +14,31 @@ env: | |
GITHUB_TOKEN: ${{ secrets.PAT_ATTACH_TO_RELEASE }} | ||
|
||
jobs: | ||
upgrade: | ||
name: Upgrade packages | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: Meadowlark-js | ||
permissions: | ||
contents: write | ||
outputs: | ||
version: ${{ steps.set-version.outputs.version }} | ||
steps: | ||
- name: Checkout the Repo | ||
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 | ||
|
||
- name: Update versions | ||
run: npx [email protected] version prerelease --exact --no-git-tag-version --yes | ||
|
||
- name: Set Version | ||
id: set-version | ||
run: | | ||
version=v$(cat lerna.json | jq -r .version) | ||
echo "version=$version" >> "$GITHUB_OUTPUT" | ||
- uses: planetscale/ghcommit-action@4131649dbf2fdf1eb34421702972a5af7b0a8731 # v0.1.18 | ||
with: | ||
commit_message: "${{ steps.set-version.outputs.version }}" | ||
repo: ${{ github.repository }} | ||
branch: ${{ github.head_ref || github.ref_name }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
create-pre-releases: | ||
name: Create Pre-Releases | ||
runs-on: ubuntu-latest | ||
needs: upgrade | ||
defaults: | ||
run: | ||
shell: pwsh | ||
working-directory: Meadowlark-js | ||
working-directory: eng/version | ||
steps: | ||
- name: Checkout the Repo | ||
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 | ||
with: | ||
# Need full Git history for calculating the version number | ||
fetch-depth: 0w | ||
|
||
- name: Create Meadowlark Pre-Release | ||
run: | | ||
npm install | ||
$version = $(node ./bump.js) | ||
if ($LASTEXITCODE -ne 0) { | ||
throw 'Unable to retrieve version number' | ||
} | ||
$version="${{needs.upgrade.outputs.version}}" | ||
"Creating pre-release $version" | Out-Host | ||
$body = @{ | ||
tag_name = $version | ||
tag_name = "$version" | ||
target_commitish = "main" | ||
name = $version | ||
body = "" | ||
|
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,27 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Licensed to the Ed-Fi Alliance under one or more agreements. | ||
// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. | ||
// See the LICENSE and NOTICES files in the project root for more information. | ||
|
||
/* | ||
* Calculates the next version number based on prior tag and commit depth. NO | ||
* COMMIT. | ||
*/ | ||
|
||
const { calculateNextVersion, callShellCommand } = require('./helper'); | ||
|
||
// `git describe` returns the last tag plus the commit depth and the short hash | ||
// for the most recent commit. Example: last tag was v0.3.0, there has been one | ||
// more commit, and the most recent has hash `g1636c72`; then the output will be | ||
// `v0.3.1-1-g1636c72` | ||
const gitDescribe = callShellCommand('git describe --first-parent --tags'); | ||
|
||
const version = calculateNextVersion(gitDescribe); | ||
if (version === null) { | ||
// eslint-disable-next-line no-console | ||
console.error(`Unable to extract version information from ${gitDescribe}`); | ||
process.exit(1); | ||
} | ||
|
||
// eslint-disable-next-line no-console | ||
console.info(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Licensed to the Ed-Fi Alliance under one or more agreements. | ||
// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. | ||
// See the LICENSE and NOTICES files in the project root for more information. | ||
|
||
const { execSync } = require('child_process'); | ||
|
||
/* Cases that this code must handle: | ||
* 1. Last tag was a release version and there have been no commits: then keep | ||
* that tag. v0.3.0 --> v0.3.0 | ||
* 2. Last tag was a release version and there have been some commits: then | ||
* calculate depth and create a pre-release. v0.3.0-10-gbad82c2 -> | ||
* v0.3.0-pre-10. | ||
* 3. Last tag was a pre-release version and there have been no commits: keep | ||
* the tag. v0.3.0-pre-10 --> v0.3.0-pre-10. | ||
* 4. Last tag was a pre-release version and there have been no commits: get the | ||
* new depth and add it to the prior depth. v0.3.0-pre-10-3-hcbd82c2 --> | ||
* v0.3.0-pre-13. | ||
*/ | ||
function calculateNextVersion(gitDescribe) { | ||
let version = gitDescribe; | ||
const properTagExpr = /^v[^-]+(?:-pre-\d+)$/; | ||
if (!gitDescribe.match(properTagExpr)) { | ||
// Parse out the components | ||
const versionExpr = /^(?<base>v[^-]+)((-pre-(?<pre>\d+))?-(?<depth>\d+)-.{8})?/; | ||
const versionMatch = gitDescribe.match(versionExpr); | ||
if (!versionMatch) { | ||
return null; | ||
} | ||
|
||
let { base, pre, depth } = versionMatch.groups; | ||
|
||
version = base; | ||
pre = pre ?? "0"; | ||
depth = depth ?? "0"; | ||
if (pre != "0" || depth != "0") { | ||
version = `${version}-pre-${Number.parseInt(pre, 10) + Number.parseInt(depth, 10)}`; | ||
} | ||
} | ||
|
||
return version; | ||
} | ||
|
||
function callShellCommand(cmd, options) { | ||
return execSync(cmd, options).toString().replace('\n', ''); | ||
} | ||
|
||
module.exports = { | ||
calculateNextVersion, | ||
callShellCommand | ||
}; |
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,18 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Licensed to the Ed-Fi Alliance under one or more agreements. | ||
// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. | ||
// See the LICENSE and NOTICES files in the project root for more information. | ||
|
||
const { calculateNextVersion } = require('./helper'); | ||
|
||
describe('given input from `git describe`', () => { | ||
describe('when calculating the next version', () => { | ||
it.each([ | ||
['v0.3.0','v0.3.0'], | ||
['v0.3.0-10-gbad82c2','v0.3.0-pre-10'], | ||
['v0.3.0-pre-10','v0.3.0-pre-10'], | ||
['v0.3.0-pre-10-3-hcbd82c2','v0.3.0-pre-13'] | ||
])('builds a proper semantic version from %s', (gitDescribe, expected) => { | ||
expect(calculateNextVersion(gitDescribe)).toBe(expected); | ||
});}); | ||
}); |
Oops, something went wrong.