-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: setup changesets for automated releases (#31)
Signed-off-by: Timo Glastra <[email protected]>
- Loading branch information
1 parent
94b121b
commit 99473d1
Showing
18 changed files
with
355 additions
and
3,949 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,21 @@ | ||
const { execSync } = require('node:child_process') | ||
|
||
const getSignedOffBy = () => { | ||
const gitUserName = execSync('git config user.name').toString('utf-8').trim() | ||
const gitEmail = execSync('git config user.email').toString('utf-8').trim() | ||
|
||
return `Signed-off-by: ${gitUserName} <${gitEmail}>` | ||
} | ||
|
||
const getAddMessage = async (changeset) => { | ||
return `docs(changeset): ${changeset.summary}\n\n${getSignedOffBy()}\n` | ||
} | ||
|
||
const getVersionMessage = async () => { | ||
return `chore(release): new version\n\n${getSignedOffBy()}\n` | ||
} | ||
|
||
module.exports = { | ||
getAddMessage, | ||
getVersionMessage, | ||
} |
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,13 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json", | ||
"changelog": "@changesets/cli/changelog", | ||
"commit": "./commit", | ||
"privatePackages": false, | ||
"fixed": [["@openwallet-foundation/*"]], | ||
"access": "public", | ||
"baseBranch": "main", | ||
"updateInternalDependencies": "patch", | ||
"snapshot": { | ||
"useCalculatedVersion": true | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: Continuous Integration | ||
|
||
on: | ||
pull_request_review: | ||
|
||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
validate: | ||
if: github.event_name != 'pull_request_review' || github.event.pull_request.head.ref == 'changeset-release/main' | ||
runs-on: ubuntu-20.04 | ||
name: Validate | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
|
||
- uses: pnpm/action-setup@v4 | ||
- name: Setup NodeJS | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 22 | ||
cache: "pnpm" | ||
|
||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Check Style | ||
run: pnpm style:check | ||
|
||
- name: Check Types | ||
run: pnpm types:check | ||
|
||
- name: Compile | ||
run: pnpm build | ||
|
||
tests: | ||
runs-on: ubuntu-20.04 | ||
name: Tests | ||
if: github.event_name != 'pull_request_review' || github.event.pull_request.head.ref == 'changeset-release/main' | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node-version: [18, 20, 22] | ||
|
||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
|
||
- uses: pnpm/action-setup@v4 | ||
- name: Setup NodeJS | ||
id: setup-node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
# See https://github.com/actions/setup-node/issues/641#issuecomment-1358859686 | ||
- name: pnpm cache path | ||
id: pnpm-cache-path | ||
run: | | ||
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | ||
- name: pnpm cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ steps.pnpm-cache-path.outputs.STORE_PATH }} | ||
key: ${{ runner.os }}-${{ steps.setup-node.outputs.node-version }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ steps.setup-node.outputs.node-version }}-pnpm-store- | ||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Run tests | ||
run: pnpm 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 |
---|---|---|
@@ -0,0 +1,102 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
jobs: | ||
release-stable: | ||
runs-on: ubuntu-20.04 | ||
name: Release Stable | ||
outputs: | ||
published: ${{ steps.changesets.outputs.published }} | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
|
||
- uses: pnpm/action-setup@v4 | ||
- name: Setup NodeJS | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 22 | ||
cache: "pnpm" | ||
|
||
- name: Install Dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Create Release Pull Request or Publish to npm | ||
id: changesets | ||
uses: changesets/action@v1 | ||
with: | ||
title: "chore(release): new version" | ||
commit: "chore(release): new version" | ||
publish: pnpm release | ||
version: pnpm changeset-version | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: Get current package version | ||
id: get_version | ||
run: echo "CURRENT_PACKAGE_VERSION=$(node -p "require('./packages/askar-shared/package.json').version")" >> $GITHUB_ENV | ||
|
||
- name: Create Github Release | ||
if: steps.changesets.outputs.published == 'true' | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
tag_name: v${{ env.CURRENT_PACKAGE_VERSION }} | ||
|
||
release-unstable: | ||
runs-on: ubuntu-20.04 | ||
name: Release Unstable | ||
needs: release-stable | ||
if: always() && github.event_name == 'push' && needs.release-stable.outputs.published == 'false' | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
|
||
- uses: pnpm/action-setup@v4 | ||
- name: Setup NodeJS | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: "pnpm" | ||
|
||
- name: Install Dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Creating .npmrc | ||
run: | | ||
cat << EOF > ".npmrc" | ||
//registry.npmjs.org/:_authToken=$NPM_TOKEN | ||
EOF | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: Create unstable release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: | | ||
# this ensures there's always a patch release created | ||
cat << 'EOF' > .changeset/snapshot-template-changeset.md | ||
--- | ||
'@openwallet-foundation/askar-shared': patch | ||
--- | ||
snapshot release | ||
EOF | ||
pnpm changeset version --snapshot alpha | ||
pnpm style:fix | ||
pnpm build | ||
pnpm changeset publish --tag alpha | ||
CURRENT_PACKAGE_VERSION=$(node -p "require('./packages/askar-shared/package.json').version") | ||
git config --global user.name "github-actions[bot]" | ||
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
git tag v$CURRENT_PACKAGE_VERSION | ||
git push origin v$CURRENT_PACKAGE_VERSION --no-verify |
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
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
Oops, something went wrong.