-
-
Notifications
You must be signed in to change notification settings - Fork 20
192 lines (185 loc) · 7.01 KB
/
node-compile.yml
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
183
184
185
186
187
188
189
190
191
192
name: Node.js Compile
on:
pull_request:
types:
# - edited # PR's base branch was changed
- opened
- reopened
- synchronize # PR's branch was edited (i.e. new commits)
release:
types:
- published
workflow_dispatch:
inputs:
tag:
description: 'Tag (e.g. "v1.0.0")'
required: true
type: string
concurrency:
group: ${{ github.workflow }}-${{ inputs.tag || github.ref }}
cancel-in-progress: true
env:
ref: ${{ inputs.tag && format('refs/tags/{0}',inputs.tag) || github.sha || github.ref }}
jobs:
path-filter:
permissions:
pull-requests: read
runs-on: ubuntu-latest
outputs:
changes: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@v4
- id: filter
uses: dorny/paths-filter@v3
with:
filters: |
changes:
- '.github/workflows/node-compile.yml'
- 'src/**'
- '*'
ref: ${{ env.ref }}
node-compile:
needs:
- path-filter
if: ${{ needs.path-filter.outputs.changes == 'true' || github.event_name != 'pull_request' }}
runs-on: ${{ matrix.os }}
name: node-compile (${{ matrix.os }} ${{ matrix.arch }})
strategy:
matrix:
include:
# docker manifest inspect node:<version> | jq '.manifests[].platform'
- os: ubuntu-latest
arch: amd64
build: |
NPM_PKG_VERSION=$(npm pkg get version | sed 's/"//g')
DOCKER_ARCH=amd64
BIN_OUTPUT="igir-${NPM_PKG_VERSION}-${RUNNER_OS}-${DOCKER_ARCH/\//}.tar.gz"
echo "BIN_OUTPUT=${BIN_OUTPUT}" >> "${GITHUB_ENV}"
docker run --rm --platform "linux/${DOCKER_ARCH}" --volume "$(pwd):/app" --workdir "/app" \
"node:$(jq --raw-output '.volta.node' package.json)" sh -c \
"npm run package . igir"
tar cvf - igir | gzip --best > "${BIN_OUTPUT}"
{
echo '```text'
ls -alh igir "${BIN_OUTPUT}"
echo '```'
} >> "${GITHUB_STEP_SUMMARY}"
- os: ubuntu-latest
arch: arm/v7
build: |
NPM_PKG_VERSION=$(npm pkg get version | sed 's/"//g')
DOCKER_ARCH=arm/v7
BIN_OUTPUT="igir-${NPM_PKG_VERSION}-${RUNNER_OS}-${DOCKER_ARCH/\//}.tar.gz"
echo "BIN_OUTPUT=${BIN_OUTPUT}" >> "${GITHUB_ENV}"
docker run --rm --platform "linux/${DOCKER_ARCH}" --volume "$(pwd):/app" --workdir "/app" \
"node:$(jq --raw-output '.volta.node' package.json)" sh -c \
"npm run package -- . igir"
tar cvf - igir | gzip --best > "${BIN_OUTPUT}"
{
echo '```text'
ls -alh igir "${BIN_OUTPUT}"
echo '```'
} >> "${GITHUB_STEP_SUMMARY}"
- os: ubuntu-latest
arch: arm64/v8
build: |
NPM_PKG_VERSION=$(npm pkg get version | sed 's/"//g')
DOCKER_ARCH=arm64/v8
BIN_OUTPUT="igir-${NPM_PKG_VERSION}-${RUNNER_OS}-${DOCKER_ARCH/\//}.tar.gz"
echo "BIN_OUTPUT=${BIN_OUTPUT}" >> "${GITHUB_ENV}"
docker run --rm --platform "linux/${DOCKER_ARCH}" --volume "$(pwd):/app" --workdir "/app" \
"node:$(jq --raw-output '.volta.node' package.json)" sh -c \
"npm run package -- . igir"
tar cvf - igir | gzip --best > "${BIN_OUTPUT}"
{
echo '```text'
ls -alh igir "${BIN_OUTPUT}"
echo '```'
} >> "${GITHUB_STEP_SUMMARY}"
- os: macos-13
build: |
NPM_PKG_VERSION=$(npm pkg get version | sed 's/"//g')
NODE_ARCH=$(node --print 'process.arch')
BIN_OUTPUT="igir-${NPM_PKG_VERSION}-${RUNNER_OS}-${NODE_ARCH}.tar.gz"
echo "BIN_OUTPUT=${BIN_OUTPUT}" >> "${GITHUB_ENV}"
npm run package -- . igir
tar cvf - igir | gzip --best > "${BIN_OUTPUT}"
{
echo '```text'
ls -alh igir "${BIN_OUTPUT}"
echo '```'
} >> "${GITHUB_STEP_SUMMARY}"
- os: macos-14
build: |
NPM_PKG_VERSION=$(npm pkg get version | sed 's/"//g')
NODE_ARCH=$(node --print 'process.arch')
BIN_OUTPUT="igir-${NPM_PKG_VERSION}-${RUNNER_OS}-${NODE_ARCH}.tar.gz"
echo "BIN_OUTPUT=${BIN_OUTPUT}" >> "${GITHUB_ENV}"
npm run package -- . igir
tar cvf - igir | gzip --best > "${BIN_OUTPUT}"
{
echo '```text'
ls -alh igir "${BIN_OUTPUT}"
echo '```'
} >> "${GITHUB_STEP_SUMMARY}"
- os: windows-latest
build: |
$NPM_PKG_VERSION=$(npm pkg get version).replace('"','')
$NODE_ARCH=$(node --print 'process.arch')
$BIN_OUTPUT="igir-$NPM_PKG_VERSION-${env:RUNNER_OS}-${NODE_ARCH}.zip"
echo "BIN_OUTPUT=${BIN_OUTPUT}" | Out-File -FilePath $env:GITHUB_ENV -Append # no need for -Encoding utf8
npm run package -- . igir.exe
Compress-Archive -Path igir.exe -DestinationPath "${BIN_OUTPUT}" -CompressionLevel Optimal -Force
echo "``````text" >> "${env:GITHUB_STEP_SUMMARY}"
Get-ChildItem igir.exe >> "${env:GITHUB_STEP_SUMMARY}"
Get-ChildItem "${BIN_OUTPUT}" >> "${env:GITHUB_STEP_SUMMARY}"
echo "``````" >> "${env:GITHUB_STEP_SUMMARY}"
steps:
# Setup and install
- uses: actions/checkout@v4
with:
ref: ${{ env.ref }}
- if: matrix.os == 'ubuntu-latest'
uses: docker/setup-qemu-action@v3
- uses: volta-cli/action@v4
- run: npm ci
- run: npm run build
# Compile and upload
- run: ${{ matrix.build }}
- if: ${{ github.event_name != 'pull_request' }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.BIN_OUTPUT }}
path: ${{ env.BIN_OUTPUT }}
if-no-files-found: error
release-update:
if: ${{ github.event_name != 'pull_request' }}
needs:
- node-compile
runs-on: ubuntu-latest
steps:
# Get the package version
- uses: actions/checkout@v4
with:
ref: ${{ env.ref }}
- uses: volta-cli/action@v4
- run: npm ci
- run: echo "NPM_PKG_VERSION=$(npm pkg get version | sed 's/"//g')" >> "${GITHUB_ENV}"
# Download and update
- uses: actions/download-artifact@v4
- uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.NPM_PKG_VERSION }}
files: igir-*/*
# !!! This check should be required by GitHub !!!
compile-status-check:
if: always()
needs:
- path-filter
- node-compile
runs-on: ubuntu-latest
steps:
- uses: re-actors/alls-green@release/v1
with:
allowed-skips: node-compile
jobs: ${{ toJSON(needs) }}