-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (143 loc) · 5.98 KB
/
build-and-publish.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
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
name: Node.js Package
on:
# release:
# types: [created]
workflow_dispatch:
# jobs:
# buildx86:
# runs-on: ubuntu-latest
# permissions:
# contents: write
# packages: write
# deployments: write
# env:
# NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-node@v3
# with:
# node-version: 20
# registry-url: https://npm.pkg.github.com/
# - uses: mmomtchev/setup-swig@v3
# with:
# branch: jse
# - run: swig -version
# # build x86_64 version, test, pack, package and native module
# - run: npm i --ignore-scripts
# - run: ./node_modules/@mapbox/node-pre-gyp/bin/node-pre-gyp rebuild package
# - run: npm run test
# - run: npm publish
# - run: NODE_PRE_GYP_GITHUB_TOKEN=$NODE_AUTH_TOKEN node ./node_modules/node-pre-gyp-github/bin/node-pre-gyp-github.js publish --release
# # # build for mac, package and upload native module
# # - run: sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
# # - run: apt-get install uuid-dev:arm64 --download-only
# # - run: curl -s https://nodejs.org/download/release/$(node --version)/node-$(node --version)-linux-arm64.tar.gz > /tmp/nodearm64.tgz
# # - run: npm i --ignore-scripts
# # - run: CCARCH=aarch64-linux-gnu CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ CC_host="gcc" CXX_host="g++" ./node_modules/@mapbox/node-pre-gyp/bin/node-pre-gyp rebuild package --tarball /tmp/nodearm64.tgz --arch=arm64
# # - run: NODE_PRE_GYP_GITHUB_TOKEN=$NODE_AUTH_TOKEN node ./node_modules/node-pre-gyp-github/bin/node-pre-gyp-github.js publish --release --arch=arm64
# archs:
# # The host should always be linux
# runs-on: ubuntu-latest
# name: Build on ${{ matrix.distro }} ${{ matrix.arch }}
# permissions:
# contents: write
# packages: write
# deployments: write
# env:
# NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
# # Run steps on a matrix of 4 arch/distro combinations
# strategy:
# matrix:
# include:
# - arch: aarch64
# distro: ubuntu_latest
# # - arch: aarch64
# # distro: bullseye
# # - arch: ppc64le
# # distro: alpine_latest
# # - arch: none
# # distro: none
# # base_image: riscv64/busybox
# steps:
# - uses: actions/checkout@v4
# # - uses: actions/setup-node@v3
# # with:
# # node-version: 20
# # registry-url: https://npm.pkg.github.com/
# # - uses: mmomtchev/setup-swig@v3
# # with:
# # branch: jse
# - uses: uraimo/run-on-arch-action@v2
# name: Build artifact
# id: build
# with:
# arch: ${{ matrix.arch }}
# distro: ${{ matrix.distro }}
# # Not required, but speeds up builds
# githubToken: ${{ github.token }}
# # The shell to run commands with in the container
# shell: /bin/sh
# # do the build
# run: |
# apt-get update
# apt-get install -y git autotools-dev autoconf libtool-bin libpcre2-dev
# apt-get satisfy -y "nodejs (<< 21.0.0)"
# git clone https://github.com/mmomtchev/swig.git && cd swig && ./autogen.sh && ./configure && make && make install && cd ..
# swig -version
# npm i --ignore-scripts
# ./node_modules/@mapbox/node-pre-gyp/bin/node-pre-gyp rebuild package
# npm run test
# NODE_PRE_GYP_GITHUB_TOKEN=$NODE_AUTH_TOKEN node ./node_modules/node-pre-gyp-github/bin/node-pre-gyp-github.js publish --release
jobs:
start-runner:
timeout-minutes: 5 # normally it only takes 1-2 minutes
name: Start self-hosted EC2 runner
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Start EC2 runner
id: start-ec2-runner
uses: NextChapterSoftware/ec2-action-builder@v1
with:
github_token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
aws_access_key_id: ${{ secrets.DEPLOY_AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.DEPLOY_AWS_SECRET_ACCESS_KEY }}
aws_region: ${{ secrets.AWS_REGION }}
ec2_instance_type: t4g.large
ec2_ami_id: ami-0c29a2c5cf69b5a9c # arm64 noble
ec2_subnet_id: ${{ secrets.SUBNET_ID }}
ec2_security_group_id: ${{ secrets.SECURITY_GROUP_ID }}
ec2_instance_ttl: 40 # Optional (default is 60 minutes)
ec2_spot_instance_strategy: BestEffort # Other options are: SpotOnly, BestEffort, MaxPerformance
# Job that runs on the self-hosted runner
run-build:
timeout-minutes: 1
needs:
- start-runner
runs-on: ${{ github.run_id }}
permissions:
contents: write
packages: write
deployments: write
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
steps:
- run: env
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://npm.pkg.github.com/
- uses: mmomtchev/setup-swig@v3
with:
branch: jse
- run: swig -version
# build native version, test, pack, package and native module
- run: npm i --ignore-scripts
- run: ./node_modules/@mapbox/node-pre-gyp/bin/node-pre-gyp rebuild package
- run: npm run test
- run: npm publish
- run: NODE_PRE_GYP_GITHUB_TOKEN=$NODE_AUTH_TOKEN node ./node_modules/node-pre-gyp-github/bin/node-pre-gyp-github.js publish --release