-
Notifications
You must be signed in to change notification settings - Fork 0
182 lines (182 loc) · 6.44 KB
/
ci.yaml
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: CI
on:
push:
branches:
- main
env:
NODE_VERSION: 20
PNPM_VERSION: 9
jobs:
release:
runs-on: ubuntu-latest
services:
mariadb:
image: mariadb:10.4
env:
MYSQL_ROOT_PASSWORD: root
volumes:
- /var/lib/mysql-files:/var/lib/mysql-files
ports:
- 127.0.0.1:3307:3306
steps:
- name: Configure MariaDB
run: |
CONTAINER_ID=${{ job.services.mariadb.id }}
docker exec $CONTAINER_ID sh -c 'echo [mysqld] > /etc/mysql/mariadb.conf.d/settings.cnf'
docker exec $CONTAINER_ID sh -c 'echo "secure_file_priv=/var/lib/mysql-files" >> /etc/mysql/mariadb.conf.d/settings.cnf'
docker kill --signal=SIGHUP $CONTAINER_ID
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- run: pnpm install
- run: pnpm build
- name: Install system dependencies
run: sudo apt-get install restic git tar pigz -y
- name: Update restic
run: sudo restic self-update
- name: Test
run: sudo npm test
env:
CI: true
- uses: actions/cache@v4
with:
path: ~/.pkg-cache/
key: ${{ runner.os }}-pkg
- run: pnpm build:dist
- run: pnpm build:bin
- name: Create release pull request or publish to npm
id: changesets
uses: changesets/action@v1
with:
commit: "chore: update versions"
title: Update versions
publish: pnpm exec changeset publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Upload release artifacts
uses: actions/upload-artifact@v4
with:
name: release-artifacts
path: bin/*
if-no-files-found: error
- id: release-name
uses: actions/github-script@v7
env:
PUBLISHED_PACKAGES: ${{ steps.changesets.outputs.publishedPackages }}
with:
script: |
const published = JSON.parse(process.env.PUBLISHED_PACKAGES);
for (const { name, version } of published)
core.setOutput(name, version);
- name: Upload release assets
if: steps.release-name.outputs['datatruck']
uses: softprops/action-gh-release@v1
with:
files: bin/*
name: datatruck@${{ steps.release-name.outputs['datatruck'] }}
tag_name: datatruck@${{ steps.release-name.outputs['datatruck'] }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Delete nightly release
uses: sgpublic/[email protected]
with:
pre-release-drop: true
pre-release-keep-count: -1
pre-release-drop-tag: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create nightly release
if: steps.release-name.outputs['datatruck'] == ''
uses: softprops/action-gh-release@v1
with:
tag_name: datatruck@nightly
name: datatruck@nightly
files: bin/*
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- id: changesets_meta
name: Build changesets meta
uses: actions/github-script@v7
env:
PUBLISHED_PACKAGES: ${{ steps.changesets.outputs.publishedPackages }}
with:
script: |-
const output = {};
const published = JSON.parse(process.env.PUBLISHED_PACKAGES);
output['@datatruck/cli:published'] = false;
published.forEach(({ name, version }) => {
const vars = { version, published: true };
Object.keys(vars).forEach(n => output[`${name}:${n}`] = vars[n]);
});
console.info(output);
Object.keys(output).forEach(k => core.setOutput(k, output[k]));
- id: image_meta
name: Build image metadata
uses: docker/metadata-action@v5
if: steps.changesets_meta.outputs['@datatruck/cli:version'] != ''
with:
images: ghcr.io/${{ github.repository }}
tags: |-
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}},value=v${{ steps.changesets_meta.outputs['@datatruck/cli:version'] }}
type=semver,pattern={{major}}.{{minor}},value=v${{ steps.changesets_meta.outputs['@datatruck/cli:version'] }}
type=semver,pattern={{major}},value=v${{ steps.changesets_meta.outputs['@datatruck/cli:version'] }}
type=sha
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login Docker
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and publish image
uses: docker/build-push-action@v5
with:
tags: ${{ steps.image_meta.outputs.tags }}
labels: ${{ steps.image_meta.outputs.labels }}
push: ${{ steps.changesets_meta.outputs['@datatruck/cli:published'] }}
release-win-setup:
runs-on: windows-latest
needs: [release]
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- uses: actions/download-artifact@v4
with:
name: release-artifacts
path: bin
- run: node scripts/build-win-setup.mjs
- name: Upload release assets
if: needs.release.steps.release-name.outputs['datatruck']
uses: softprops/action-gh-release@v1
with:
files: bin/*
name: datatruck@${{ needs.release.steps.release-name.outputs['datatruck'] }}
tag_name: datatruck@${{ needs.release.steps.release-name.outputs['datatruck'] }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create nightly release
if: needs.release.steps.release-name.outputs['datatruck'] == ''
uses: softprops/action-gh-release@v1
with:
tag_name: datatruck@nightly
name: datatruck@nightly
files: bin/*
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}