Skip to content

Commit

Permalink
try ec2 arm instances
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-page committed May 6, 2024
1 parent 0993d60 commit bc4bc5b
Showing 1 changed file with 108 additions and 55 deletions.
163 changes: 108 additions & 55 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
# types: [created]
workflow_dispatch:

jobs:
# jobs:
# buildx86:
# runs-on: ubuntu-latest
# permissions:
Expand Down Expand Up @@ -41,61 +41,114 @@ jobs:
# # - 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}}
# 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 }}

# 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 }}
# # The shell to run commands with in the container
# shell: /bin/sh

# Not required, but speeds up builds
githubToken: ${{ github.token }}
# # 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


# The shell to run commands with in the container
shell: /bin/sh
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

# 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
# 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

0 comments on commit bc4bc5b

Please sign in to comment.