forked from shiftkey/node-keytar
-
Notifications
You must be signed in to change notification settings - Fork 0
169 lines (140 loc) · 5.12 KB
/
ci.yml
File metadata and controls
169 lines (140 loc) · 5.12 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: CI
on:
push:
branches: [ master ]
tags:
- v*.*.*
pull_request:
branches: [ master ]
permissions:
contents: write # to allow workflow to publish release
jobs:
build:
name: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
node-version: [22.x]
os: [ubuntu-20.04-xl, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
- run: |
sudo apt-get install gnome-keyring \
libsecret-1-dev \
dbus-x11 \
python3-dev
if: ${{ matrix.os == 'ubuntu-20.04-xl' }}
name: Install additional dependencies
- run: npm ci
name: Setup environment
- run: npm run build
name: Build native module from source
- run: |
echo "Install keyring..."
pip3 install --upgrade pip
pip3 install keyring
echo "Prepare D-Bus session..."
eval $(dbus-launch --sh-syntax);
eval $(echo 'somecredstorepass' | gnome-keyring-daemon --unlock)
echo "Create a test key using script..."
python -c "import keyring;keyring.set_password('system', 'login', 'pwd');"
npm test
if: ${{ matrix.os == 'ubuntu-20.04-xl' }}
name: Run tests (Linux)
- run: npm test
if: ${{ matrix.os != 'ubuntu-20.04-xl' }}
name: Run tests (Windows/macOS)
- run: npm run prebuild-napi-x64
name: Prebuild (x64)
- run: npm run prebuild-napi-arm64
name: Prebuild (arm64)
if: ${{ matrix.os != 'ubuntu-20.04-xl' }}
- run: npm run prebuild-napi-ia32
if: ${{ matrix.os == 'windows-2019' }}
name: Prebuild (Windows x86)
- run: |
mkdir -p prebuilds && chmod 777 prebuilds
docker build -t node-keytar/i386 docker/i386
docker run --rm -v ${PWD}:/project node-keytar/i386 /bin/bash -c "cd /project && npm run prebuild-napi-ia32 && rm -rf build"
docker build -t node-keytar/arm64-cross-compile docker/arm64-cross-compile
docker run --rm -v ${PWD}:/project node-keytar/arm64-cross-compile /bin/bash -c "cd /project && npm run prebuild-napi-arm64 && rm -rf build"
docker run --rm -v ${PWD}:/project node-keytar/arm64-cross-compile /bin/bash -c "cd /project && npm run prebuild-napi-arm && rm -rf build"
docker build -t node-keytar/armv7l-cross-compile docker/armv7l-cross-compile
docker run --rm -v ${PWD}:/project node-keytar/armv7l-cross-compile /bin/bash -c "cd /project && npm run prebuild-napi-armv7l"
if: ${{ matrix.os == 'ubuntu-20.04-xl' }}
name: Prebuild (Linux x86 + ARM64 + ARMV7L)
- run: |
ls -R prebuilds/
name: List prebuilds
shell: bash
# untar each prebuild file named *<platform>-<arch>.tar.gz
# and move its build/Release/ contents to a directory <platform>-<arch>/
- run: |
for f in *.tar.gz; do
platform_arch="${f%.tar.gz}"
platform_arch="${platform_arch##*-v3-}"
mkdir -p "$platform_arch"
tar -xzf "$f" -C "$platform_arch" --strip-components=2
done
rm *.tar.gz
name: Extract prebuilds
shell: bash
working-directory: prebuilds
- uses: actions/upload-artifact@v4
with:
name: prebuild-${{ matrix.os }}
path: prebuilds/
- name: Upload prebuilds to GitHub
run: npx prebuild --verbose --upload-all ${{ secrets.GITHUB_TOKEN }}
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
alpine-build:
runs-on: ubuntu-20.04-xl
container: node:22-alpine3.20
steps:
- uses: actions/checkout@v4
- name: install additional dependencies
run: |
apk add g++ make python3 libsecret-dev
- run: npm ci
name: Setup environment
- run: |
npm run prebuild-napi-x64
npm run prebuild-napi-arm64
npm run prebuild-napi-arm
name: Prebuild
- run: |
ls prebuilds/
name: List prebuilds
- name: Upload prebuilds to GitHub
run: npx prebuild --verbose --upload-all ${{ secrets.GITHUB_TOKEN }}
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
# Separate step for publishing to NPM so we're sure that generating + uploading prebuilds worked on all platforms
npm-publish:
needs: [build, alpine-build]
name: Publish to NPM
runs-on: ubuntu-20.04-xl
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
registry-url: 'https://registry.npmjs.org'
- run: sudo apt-get install libsecret-1-dev
name: Install additional dependencies
- run: npm ci
name: Setup environment
- uses: actions/download-artifact@v4
with:
path: prebuilds
merge-multiple: true
- run: npm publish --access public
name: Upload to NPM
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}