Skip to content

Commit ce3814e

Browse files
authored
chore(ops): update semver checks to package (#2146)
<!-- Thanks for sending a pull request! --> #### What this PR does / why we need it: Implement proper semver versioning for our releases. Currently, it only allows `major.minor.patch`. It doesn't support beta/rc tags. #### Which issue(s) does this PR fixes?: <!-- (Optional) Automatically closes linked issue when PR is merged. Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`. --> Fixes # #### Additional comments?:
1 parent 79a4f60 commit ce3814e

7 files changed

Lines changed: 38 additions & 24 deletions

File tree

.github/scripts/release-ecr-tags.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ module.exports = ({ context }) => {
1313
}
1414

1515
function getReleaseTag(context) {
16-
const semver = context.payload.release.tag_name
17-
if (semver.match(/^v[0-9]+\.[0-9]+\.[0-9]+$/) === null) {
16+
const semver = require("semver");
17+
const version = context.payload.release.tag_name;
18+
if (!semver.valid(version)) {
1819
throw new Error(`Release Violation: Provided version '${semver}' is not valid semver.`)
1920
}
20-
return semver.replace('v','')
21+
return version.replace('v','')
2122
}

.github/scripts/release-tags.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ function getDomain(context) {
5555
}
5656

5757
function getReleaseTag(domain, app, context) {
58-
const semver = context.payload.release.tag_name
59-
if (semver.match(/^v[0-9]+\.[0-9]+\.[0-9]+$/) === null) {
60-
throw new Error(`Release Violation: Provided version '${semver}' is not valid semver.`)
58+
const semver = require("semver");
59+
const version = context.payload.release.tag_name;
60+
if (!semver.valid(version)) {
61+
throw new Error(`Release Violation: Provided version '${version}' is not valid semver.`)
6162
}
62-
return `ghcr.io/${domain}/${app}:latest,ghcr.io/${domain}/${app}:${semver.replace('v','')}`
63+
return `ghcr.io/${domain}/${app}:latest,ghcr.io/${domain}/${app}:${version.replace('v','')}`
6364
}
6465

6566
function getMainTag(domain, app, { sha }) {

.github/workflows/release-apps.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ jobs:
3939
username: ${{ github.repository_owner }}
4040
password: ${{ secrets.GITHUB_TOKEN }}
4141

42+
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
43+
with:
44+
node-version-file: '.nvmrc'
45+
46+
- run: npm ci
47+
4248
- name: Resolve Tags
4349
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
4450
id: tags

.github/workflows/release-ecr.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ jobs:
2222
steps:
2323
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
2424

25+
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
26+
with:
27+
node-version-file: '.nvmrc'
28+
29+
- run: npm ci
30+
2531
- name: Set up QEMU
2632
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 # v2.1.0
2733

.github/workflows/release-publish.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,15 @@ jobs:
1616
with:
1717
node-version-file: '.nvmrc'
1818

19-
- uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
19+
- run: npm ci
20+
21+
- name: Resolve Version
22+
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
2023
id: version
2124
with:
22-
script: |
23-
const semver = context.ref.replace('refs/tags/v', '')
24-
if (semver.match(/^[0-9]+\.[0-9]+\.[0-9]+$/)) {
25-
return semver
26-
}
27-
throw new Error('not semver')
25+
script: return require('./.github/scripts/release-ecr-tags.js')({ context })
2826
result-encoding: string
2927

30-
- run: npm ci
3128
- run: npm run all:build
3229
- run: npm run all:version ${{ steps.version.outputs.result }}
3330

package-lock.json

Lines changed: 11 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"lerna": "5.1.8",
3737
"lint-staged": "13.2.3",
3838
"nock": "13.3.0",
39+
"semver": "^7.5.4",
3940
"shuffle-seed": "1.1.6",
4041
"ts-jest": "27.1.5",
4142
"typescript": "4.2.4",

0 commit comments

Comments
 (0)