-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
79d18b9
commit 67afe67
Showing
13 changed files
with
480 additions
and
176 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,54 @@ | ||
name: CI/CD | ||
|
||
on: | ||
push: | ||
branches: | ||
- "**" | ||
paths: | ||
- .github/workflows/ci-cd.yml | ||
- src/** | ||
- scripts/** | ||
- test/** | ||
- Directory.Build.props | ||
tags: | ||
- "**" | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: write # Needed to create a GitHub Release | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
# Build | ||
- run: dotnet build --configuration Release | ||
# Test | ||
- run: dotnet test --configuration Release --no-build --collect:"XPlat Code Coverage" | ||
env: | ||
AWS_REGION: eu-west-1 | ||
AWS_USER_WITH_PERMISSIONS_ACCESS_KEY_ID: ${{ secrets.AWS_USER_WITH_PERMISSIONS_ACCESS_KEY_ID }} | ||
AWS_USER_WITH_PERMISSIONS_SECRET_ACCESS_KEY: ${{ secrets.AWS_USER_WITH_PERMISSIONS_SECRET_ACCESS_KEY }} | ||
AWS_USER_WITHOUT_PERMISSIONS_ACCESS_KEY_ID: ${{ secrets.AWS_USER_WITHOUT_PERMISSIONS_ACCESS_KEY_ID }} | ||
AWS_USER_WITHOUT_PERMISSIONS_SECRET_ACCESS_KEY: ${{ secrets.AWS_USER_WITHOUT_PERMISSIONS_SECRET_ACCESS_KEY }} | ||
AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} | ||
AWS_API_GATEWAY_URL: ${{ secrets.AWS_API_GATEWAY_URL }} | ||
AWS_S3_BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME }} | ||
AWS_S3_BUCKET_URL: ${{ secrets.AWS_S3_BUCKET_URL }} | ||
- uses: codecov/codecov-action@v3 | ||
# Pack | ||
- run: dotnet pack --configuration Release --no-build | ||
- run: | | ||
mkdir dist | ||
mv src/bin/Release/*.nupkg ./dist | ||
mv src/bin/Release/*.snupkg ./dist | ||
# Release | ||
- run: | | ||
pushd ./scripts | ||
npm ci | ||
npm run release | ||
popd | ||
if: startsWith(github.ref, 'refs/tags/') | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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 @@ | ||
name: infrastructure | ||
|
||
on: | ||
push: | ||
branches: | ||
- "**" | ||
paths: | ||
- .github/workflows/infrastructure.yml | ||
- infrastructure/** | ||
workflow_dispatch: | ||
|
||
defaults: | ||
run: | ||
working-directory: infrastructure | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: lts/* | ||
check-latest: true | ||
- run: npm ci | ||
- run: npm run build | ||
- run: npm run lint |
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/node_modules |
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,12 @@ | ||
// @ts-check | ||
|
||
// GitHub token | ||
export const GITHUB_TOKEN = process.env.GITHUB_TOKEN ?? ''; | ||
|
||
// git tag | ||
const prefix = 'refs/tags/'; | ||
const ref = process.env.GITHUB_REF ?? ''; | ||
export const GIT_TAG = ref.startsWith(prefix) ? ref.substring(prefix.length) : ''; | ||
|
||
// Repo slug, e.g. "owner_name/repo_name" | ||
export const REPO = process.env.GITHUB_REPOSITORY ?? ''; |
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 @@ | ||
// @ts-check | ||
|
||
import { Octokit } from '@octokit/rest'; | ||
import { readFileSync } from 'fs'; | ||
import { basename } from 'path'; | ||
import { info } from './log.js'; | ||
|
||
/** | ||
* @param {string} githubToken | ||
* @param {string} owner | ||
* @param {string} repo | ||
* @param {string} tagName | ||
* @param {string} version | ||
*/ | ||
export const createRelease = async (githubToken, owner, repo, tagName, version) => { | ||
info(`github: create release from tag ${tagName}`); | ||
|
||
const octokit = new Octokit({ | ||
auth: githubToken, | ||
}); | ||
|
||
const release = await octokit.repos.createRelease({ | ||
owner, | ||
repo, | ||
tag_name: tagName, | ||
name: `Release ${version}`, | ||
body: 'TODO', | ||
draft: true, | ||
}); | ||
|
||
return { | ||
releaseId: release.data.id, | ||
}; | ||
}; | ||
|
||
/** | ||
* @param {string} githubToken | ||
* @param {string} owner | ||
* @param {string} repo | ||
* @param {number} releaseId | ||
* @param {string} assetFileName | ||
*/ | ||
export const uploadAsset = async (githubToken, owner, repo, releaseId, assetFileName) => { | ||
info(`github: upload asset ${assetFileName}`); | ||
|
||
const octokit = new Octokit({ | ||
auth: githubToken, | ||
}); | ||
|
||
await octokit.repos.uploadReleaseAsset({ | ||
owner, | ||
repo, | ||
release_id: releaseId, | ||
name: basename(assetFileName), | ||
data: readFileSync(assetFileName).toString(), | ||
}); | ||
}; |
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 @@ | ||
// @ts-check | ||
|
||
export const RED = '[31m'; | ||
export const YELLOW = '[33;1m'; | ||
|
||
/** | ||
* @param {string} message | ||
*/ | ||
export const info = (message) => { | ||
console.log(message); | ||
}; | ||
|
||
/** | ||
* @param {string} message | ||
*/ | ||
export const error = (message) => { | ||
log(RED, message); | ||
}; | ||
|
||
/** | ||
* @param {string} message | ||
*/ | ||
export const fatal = (message) => { | ||
log(RED, message); | ||
process.exitCode = 1; | ||
}; | ||
|
||
/** | ||
* @param {string} color | ||
* @param {string} message | ||
*/ | ||
export const log = (color, message) => { | ||
console.log('\x1b%s%s\x1b[0m', color, message); | ||
}; |
Oops, something went wrong.