-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from CloudCannon/feat/pipelines
Release pipeline
- Loading branch information
Showing
14 changed files
with
702 additions
and
43,737 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const version = process.env.GIT_VERSION; | ||
|
||
if (!version) { | ||
console.error('Script expected a GIT_VERSION environment variable'); | ||
process.exit(1); | ||
} | ||
|
||
// Only allow latest tag if we are releasing a major/minor/patch | ||
if (/^\d+\.\d+\.\d+$/.test(version)) { | ||
console.log('latest'); | ||
process.exit(0); | ||
} | ||
|
||
// Use the suffix as the tag. i.e. `0.11.0-rc.5` -> `rc` | ||
const suffix = version.match(/^\d+\.\d+\.\d+-([a-z]+)\.\d+$/i)?.[1]; | ||
if (suffix) { | ||
console.log(suffix.toLowerCase()); | ||
process.exit(0); | ||
} | ||
|
||
console.error(`No release tag found for ${version} — exiting`); | ||
process.exit(1); |
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 @@ | ||
let cp = require("child_process"); | ||
|
||
let output = cp | ||
.execSync("git describe --tags | sed 's/^v\\(.*\\)$/\\1/'") | ||
.toString() | ||
.trim(); | ||
|
||
let ver_regex = /^\d+\.\d+\.\d+(-[a-z]+\.\d+)?$/i; | ||
|
||
if (!ver_regex.test(output)) { | ||
console.error(`Version ${output} doesn't match our versioning spec.`); | ||
console.error( | ||
`Valid version samples: 0.1.0 / 1.2.3 / 1.5.0-alpha.0 / 1.1.1-rc.8` | ||
); | ||
process.exit(1); | ||
} | ||
|
||
console.log(output); |
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,104 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- v* | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- name: Clone | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install | ||
run: npm ci | ||
|
||
- name: Build | ||
run: npm run build | ||
|
||
- name: Unit Test | ||
run: npm run test | ||
|
||
publish-github-release: | ||
name: Publish to GitHub | ||
runs-on: ubuntu-24.04 | ||
needs: test | ||
steps: | ||
- name: Get Token | ||
id: get_workflow_token | ||
uses: peter-murray/workflow-application-token-action@v2 | ||
with: | ||
application_id: ${{ secrets.CC_OSS_BOT_ID }} | ||
application_private_key: ${{ secrets.CC_OSS_BOT_PEM }} | ||
|
||
- name: Swap to main | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: main | ||
fetch-depth: 0 # Full fetch | ||
token: ${{ steps.get_workflow_token.outputs.token }} | ||
|
||
- name: Get Version | ||
run: | | ||
GIT_VERSION=$(node ./.backstage/get_tagged_version.cjs) | ||
echo GIT_VERSION="$GIT_VERSION" >> $GITHUB_ENV | ||
- name: Get Release Tag | ||
run: | | ||
NPM_TAG=$(node ./.backstage/get_npm_tag.cjs) | ||
echo NPM_TAG="$NPM_TAG" >> $GITHUB_ENV | ||
- name: Stable Release | ||
uses: softprops/action-gh-release@v2 | ||
if: startsWith(github.ref, 'refs/tags/') && env.NPM_TAG == 'latest' | ||
env: | ||
GITHUB_TOKEN: ${{ steps.get_workflow_token.outputs.token }} | ||
|
||
- name: Prerelease | ||
uses: softprops/action-gh-release@v2 | ||
if: startsWith(github.ref, 'refs/tags/') && env.NPM_TAG != 'latest' | ||
with: | ||
prerelease: true | ||
env: | ||
GITHUB_TOKEN: ${{ steps.get_workflow_token.outputs.token }} | ||
|
||
publish-npm-release: | ||
runs-on: ubuntu-24.04 | ||
needs: publish-github-release | ||
steps: | ||
- name: Clone | ||
uses: actions/checkout@v3 | ||
|
||
- name: Get Version | ||
run: | | ||
GIT_VERSION=$(node ./.backstage/get_tagged_version.cjs) | ||
echo GIT_VERSION="$GIT_VERSION" >> $GITHUB_ENV | ||
- name: Get Release Tag | ||
run: | | ||
NPM_TAG=$(node ./.backstage/get_npm_tag.cjs) | ||
echo NPM_TAG="$NPM_TAG" >> $GITHUB_ENV | ||
- name: Prepare package | ||
run: | | ||
npm --no-git-tag-version version $GIT_VERSION | ||
- name: Install | ||
run: npm ci | ||
|
||
- name: Build | ||
run: npm run build | ||
|
||
- name: Publish internal | ||
uses: JS-DevTools/npm-publish@v3 | ||
with: | ||
tag: ${{ env.NPM_TAG }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
registry: "https://npm.pkg.github.com" | ||
|
||
- name: Publish external | ||
uses: JS-DevTools/npm-publish@v3 | ||
with: | ||
tag: ${{ env.NPM_TAG }} | ||
token: ${{ secrets.NPM_TOKEN }} | ||
access: public |
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,34 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ${{matrix.os}} | ||
defaults: | ||
run: | ||
shell: bash | ||
strategy: | ||
matrix: | ||
include: | ||
- build: linux | ||
os: ubuntu-24.04 | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Install | ||
run: npm ci | ||
|
||
- name: Build | ||
run: npm run build | ||
|
||
- name: Unit Test | ||
run: npm run test |
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 +1,2 @@ | ||
node_modules/ | ||
build/ |
Oops, something went wrong.