diff --git a/.github/scripts/release-ecr-tags.js b/.github/scripts/release-ecr-tags.js index cf10de6fde..5af7fe6804 100644 --- a/.github/scripts/release-ecr-tags.js +++ b/.github/scripts/release-ecr-tags.js @@ -13,9 +13,10 @@ module.exports = ({ context }) => { } function getReleaseTag(context) { - const semver = context.payload.release.tag_name - if (semver.match(/^v[0-9]+\.[0-9]+\.[0-9]+$/) === null) { + const semver = require("semver"); + const version = context.payload.release.tag_name; + if (!semver.valid(version)) { throw new Error(`Release Violation: Provided version '${semver}' is not valid semver.`) } - return semver.replace('v','') + return version.replace('v','') } diff --git a/.github/scripts/release-tags.js b/.github/scripts/release-tags.js index 72a05b58fc..ee6ef003ad 100644 --- a/.github/scripts/release-tags.js +++ b/.github/scripts/release-tags.js @@ -55,11 +55,12 @@ function getDomain(context) { } function getReleaseTag(domain, app, context) { - const semver = context.payload.release.tag_name - if (semver.match(/^v[0-9]+\.[0-9]+\.[0-9]+$/) === null) { - throw new Error(`Release Violation: Provided version '${semver}' is not valid semver.`) + const semver = require("semver"); + const version = context.payload.release.tag_name; + if (!semver.valid(version)) { + throw new Error(`Release Violation: Provided version '${version}' is not valid semver.`) } - return `ghcr.io/${domain}/${app}:latest,ghcr.io/${domain}/${app}:${semver.replace('v','')}` + return `ghcr.io/${domain}/${app}:latest,ghcr.io/${domain}/${app}:${version.replace('v','')}` } function getMainTag(domain, app, { sha }) { diff --git a/.github/workflows/release-apps.yml b/.github/workflows/release-apps.yml index 15b5097901..fe1ee64b1f 100644 --- a/.github/workflows/release-apps.yml +++ b/.github/workflows/release-apps.yml @@ -39,6 +39,12 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 + with: + node-version-file: '.nvmrc' + + - run: npm ci + - name: Resolve Tags uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1 id: tags diff --git a/.github/workflows/release-ecr.yml b/.github/workflows/release-ecr.yml index 37b228677f..f6993453be 100644 --- a/.github/workflows/release-ecr.yml +++ b/.github/workflows/release-ecr.yml @@ -22,6 +22,12 @@ jobs: steps: - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 + with: + node-version-file: '.nvmrc' + + - run: npm ci + - name: Set up QEMU uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 # v2.1.0 diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml index 000a905784..d799eeab50 100644 --- a/.github/workflows/release-publish.yml +++ b/.github/workflows/release-publish.yml @@ -16,18 +16,15 @@ jobs: with: node-version-file: '.nvmrc' - - uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1 + - run: npm ci + + - name: Resolve Version + uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1 id: version with: - script: | - const semver = context.ref.replace('refs/tags/v', '') - if (semver.match(/^[0-9]+\.[0-9]+\.[0-9]+$/)) { - return semver - } - throw new Error('not semver') + script: return require('./.github/scripts/release-ecr-tags.js')({ context }) result-encoding: string - - run: npm ci - run: npm run all:build - run: npm run all:version ${{ steps.version.outputs.result }} diff --git a/package-lock.json b/package-lock.json index af857c4183..6a3955cb6f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,7 @@ "lerna": "5.1.8", "lint-staged": "13.2.3", "nock": "13.3.0", + "semver": "^7.5.4", "shuffle-seed": "1.1.6", "ts-jest": "27.1.5", "typescript": "4.2.4", @@ -22396,9 +22397,9 @@ } }, "node_modules/semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dependencies": { "lru-cache": "^6.0.0" }, @@ -34666,6 +34667,7 @@ "lerna": "5.1.8", "lint-staged": "13.2.3", "nock": "13.3.0", + "semver": "^7.5.4", "shuffle-seed": "1.1.6", "ts-jest": "27.1.5", "typescript": "4.2.4", @@ -50615,9 +50617,9 @@ } }, "semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "requires": { "lru-cache": "^6.0.0" } @@ -60721,9 +60723,9 @@ } }, "semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "requires": { "lru-cache": "^6.0.0" } diff --git a/package.json b/package.json index 6eb9de3111..508d20e450 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "lerna": "5.1.8", "lint-staged": "13.2.3", "nock": "13.3.0", + "semver": "^7.5.4", "shuffle-seed": "1.1.6", "ts-jest": "27.1.5", "typescript": "4.2.4",