Skip to content

Commit b438762

Browse files
add CI
Signed-off-by: Berend Sliedrecht <[email protected]>
1 parent d69a478 commit b438762

File tree

2 files changed

+176
-0
lines changed

2 files changed

+176
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Continuous Integration
2+
3+
on:
4+
pull_request_review:
5+
6+
pull_request:
7+
branches:
8+
- main
9+
push:
10+
branches:
11+
- main
12+
13+
jobs:
14+
validate:
15+
if: github.event_name != 'pull_request_review' || github.event.pull_request.head.ref == 'changeset-release/main'
16+
runs-on: ubuntu-latest
17+
name: Validate
18+
steps:
19+
- name: Checkout Repo
20+
uses: actions/checkout@v4
21+
22+
- uses: pnpm/action-setup@v4
23+
- name: Setup NodeJS
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: 20
27+
cache: "pnpm"
28+
29+
- name: Install dependencies
30+
run: pnpm install --frozen-lockfile
31+
32+
- name: Check Style
33+
run: pnpm style:check
34+
35+
- name: Check Types
36+
run: pnpm types:check
37+
38+
- name: Compile
39+
run: pnpm build
40+
41+
tests:
42+
runs-on: ubuntu-latest
43+
name: Tests
44+
if: github.event_name != 'pull_request_review' || github.event.pull_request.head.ref == 'changeset-release/main'
45+
46+
steps:
47+
- name: Checkout Repo
48+
uses: actions/checkout@v4
49+
50+
- uses: pnpm/action-setup@v4
51+
- name: Setup NodeJS
52+
id: setup-node
53+
uses: actions/setup-node@v4
54+
with:
55+
node-version: 20
56+
57+
- name: pnpm cache path
58+
id: pnpm-cache-path
59+
run: |
60+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
61+
62+
- name: pnpm cache
63+
uses: actions/cache@v3
64+
with:
65+
path: ${{ steps.pnpm-cache-path.outputs.STORE_PATH }}
66+
key: ${{ runner.os }}-${{ steps.setup-node.outputs.node-version }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
67+
restore-keys: |
68+
${{ runner.os }}-${{ steps.setup-node.outputs.node-version }}-pnpm-store-
69+
70+
- name: Install dependencies
71+
run: pnpm install --frozen-lockfile
72+
73+
- name: Run tests
74+
run: pnpm test

.github/workflows/release.yaml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency: ${{ github.workflow }}-${{ github.ref }}
9+
10+
jobs:
11+
release-stable:
12+
runs-on: ubuntu-latest
13+
name: Release Stable
14+
outputs:
15+
published: ${{ steps.changesets.outputs.published }}
16+
steps:
17+
- name: Checkout Repo
18+
uses: actions/checkout@v4
19+
20+
- uses: pnpm/action-setup@v4
21+
- name: Setup NodeJS
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: 20
25+
cache: "pnpm"
26+
27+
- name: Install Dependencies
28+
run: pnpm install --frozen-lockfile
29+
30+
- name: Create Release Pull Request or Publish to npm
31+
id: changesets
32+
uses: changesets/action@v1
33+
with:
34+
title: "chore(release): new version"
35+
commit: "chore(release): new version"
36+
publish: pnpm release
37+
version: pnpm changeset-version
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
41+
42+
- name: Get current package version
43+
id: get_version
44+
run: echo "CURRENT_PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
45+
46+
- name: Create Github Release
47+
if: steps.changesets.outputs.published == 'true'
48+
uses: softprops/action-gh-release@v2
49+
with:
50+
tag_name: v${{ env.CURRENT_PACKAGE_VERSION }}
51+
52+
release-unstable:
53+
runs-on: ubuntu-latest
54+
name: Release Unstable
55+
needs: release-stable
56+
if: always() && github.event_name == 'push' && needs.release-stable.outputs.published == 'false'
57+
steps:
58+
- name: Checkout Repo
59+
uses: actions/checkout@v4
60+
61+
- uses: pnpm/action-setup@v4
62+
- name: Setup NodeJS
63+
uses: actions/setup-node@v4
64+
with:
65+
node-version: 20
66+
cache: "pnpm"
67+
68+
- name: Install Dependencies
69+
run: pnpm install --frozen-lockfile
70+
71+
- name: Creating .npmrc
72+
run: |
73+
cat << EOF > ".npmrc"
74+
//registry.npmjs.org/:_authToken=$NPM_TOKEN
75+
EOF
76+
env:
77+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
78+
79+
- name: Create unstable release
80+
env:
81+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
83+
run: |
84+
# this ensures there's always a patch release created
85+
cat << 'EOF' > .changeset/snapshot-template-changeset.md
86+
---
87+
'@animo-id/eudi-wallet-functionality': patch
88+
---
89+
90+
snapshot release
91+
EOF
92+
93+
pnpm changeset version --snapshot alpha
94+
pnpm style:fix
95+
pnpm build
96+
pnpm changeset publish --tag alpha
97+
98+
CURRENT_PACKAGE_VERSION=$(node -p "require('./package.json').version")
99+
git config --global user.name "github-actions[bot]"
100+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
101+
git tag v$CURRENT_PACKAGE_VERSION
102+
git push origin v$CURRENT_PACKAGE_VERSION --no-verify

0 commit comments

Comments
 (0)