forked from DouglasNeuroInformatics/OpenDataCapture
-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (152 loc) · 5.11 KB
/
Copy pathrelease.yaml
File metadata and controls
152 lines (152 loc) · 5.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: Release
on:
push:
branches: ['main']
workflow_dispatch:
permissions:
contents: write
packages: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
configure:
runs-on: ubuntu-latest
outputs:
should_release: ${{ steps.version.outputs.should_release }}
version: ${{ steps.version.outputs.version }}
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Checkout Repository
uses: actions/checkout@v6
- name: Derive Build Matrix
id: matrix
run: |
matrix=$(docker compose config --no-interpolate --format json \
| jq -c '{include:[.services|to_entries[]|select(.value.build and .value.image)|{image:(.value.image|split(":")[0]),dockerfile:.value.build.dockerfile}]}')
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
- name: Determine Release Version
id: version
uses: actions/github-script@v7
with:
script: |
await require('./.github/scripts/release.cjs')({ context, core, github, exec, glob, io })
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v6
- name: Setup PNPM
uses: pnpm/action-setup@v6
- name: Setup Node
uses: actions/setup-node@v6
with:
cache: pnpm
node-version-file: '.nvmrc'
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Validate
run: GATEWAY_DATABASE_URL=file:${TMPDIR}tmp.db pnpm lint
build:
runs-on: ubuntu-latest
needs: [configure, validate]
if: ${{ needs.configure.outputs.should_release == 'true' }}
strategy:
fail-fast: true
matrix: ${{ fromJSON(needs.configure.outputs.matrix) }}
steps:
- name: Checkout Repository
uses: actions/checkout@v6
- name: Set Up QEMU
uses: docker/setup-qemu-action@v3
- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ matrix.image }}
tags: |
type=raw,value=latest
type=raw,value=${{ needs.configure.outputs.version }}
- name: Build and Push Docker Images
uses: docker/build-push-action@v6
with:
build-args: |
RELEASE_VERSION=${{ needs.configure.outputs.version }}
context: .
file: ${{ matrix.dockerfile }}
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
publish-npm:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # mint an OIDC token for npm trusted publishing (no NPM_TOKEN needed)
needs:
- build
- configure
if: ${{ needs.configure.outputs.should_release == 'true' }}
steps:
- name: Checkout Repository
uses: actions/checkout@v6
- name: Setup PNPM
uses: pnpm/action-setup@v6
- name: Setup Node
uses: actions/setup-node@v6
with:
cache: pnpm
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Print Tool Versions
run: |
echo "pnpm: $(pnpm --version)"
echo "npm: $(npm --version)"
echo "node: $(node --version)"
- name: Build Publishable Packages
run: |
# Build each publishable package and its dependency closure (turbo skips
# packages that have no build script, e.g. those that publish source directly).
filters=()
while IFS=$'\t' read -r name version pkgPath; do
filters+=("--filter=${name}...")
done < <(scripts/list-publishable.sh)
pnpm exec turbo run build "${filters[@]}"
- name: Publish Packages
run: |
# Publish each marked package whose version is not already on npm. The version
# check keeps this idempotent across workflow re-runs.
while IFS=$'\t' read -r name version pkgPath; do
if [ -n "$(npm view "${name}@${version}" version 2>/dev/null)" ]; then
echo "Skipping ${name}@${version} (already published)"
continue
fi
echo "Publishing ${name}@${version}"
pnpm --filter "${name}" publish --no-git-checks
done < <(scripts/list-publishable.sh)
release:
runs-on: ubuntu-latest
needs:
- build
- configure
- publish-npm
steps:
- name: Checkout Repository
uses: actions/checkout@v6
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.configure.outputs.version }}