Skip to content

Commit

Permalink
.github: added github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
thom-nic committed Dec 14, 2021
1 parent 75ffc8d commit 663bac5
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 1 deletion.
101 changes: 101 additions & 0 deletions .github/workflows/build-pack-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Prebuildify, package, publish

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
release:
types: [ prereleased, released ]

jobs:

build:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [x64] #, arm, arm64]
steps:
- uses: actions/checkout@v2
#- uses: docker/setup-qemu-action@v1
# with:
# image: tonistiigi/binfmt:latest
# platforms: arm,arm64 #all
- run: docker build . -f ./Dockerfile-${{ matrix.arch }}
--tag voltserver/node-bcrypt-builder-${{ matrix.arch }}
- run: docker create --name node-bcryptjs-builder voltserver/node-bcrypt-builder-${{ matrix.arch }}
- run: docker cp "node-bcryptjs-builder:/usr/local/opt/bcrypt-js/prebuilds" .
- run: find prebuilds
- uses: actions/upload-artifact@v2
with:
name: prebuild-${{ matrix.arch }}
path: ./prebuilds

pack:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- uses: actions/download-artifact@v2
with:
path: /tmp/prebuilds/
- name: Coalesce prebuilds from build matrix
run: |
mkdir prebuilds
for d in /tmp/prebuilds/*; do
mv $d/* prebuilds/
done
- run: chmod a+x prebuilds/*/*.node && find prebuilds -executable -type f
- run: echo "PACK_FILE=$(npm pack)" >> $GITHUB_ENV
- uses: actions/upload-artifact@v2
with:
name: package-tgz
path: ${{ env.PACK_FILE }}

publish-npm:
needs: pack
if: github.event_name == 'release' && contains('prereleased,released', github.event.action)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'
- uses: actions/download-artifact@v2
with:
name: package-tgz
path: /tmp/package/
- run: npm publish /tmp/package/voltserver-bcrypt3*.tgz
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

publish-gpr:
needs: pack
if: github.event_name == 'release' && contains('prereleased,released', github.event.action)
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
registry-url: https://npm.pkg.github.com/
- uses: actions/download-artifact@v2
with:
name: package-tgz
path: /tmp/package/
- run: npm publish /tmp/package/voltserver-bcrypt*.tgz
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}




29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: Test on PR/ Merge

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test-and-build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x, 16.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm i -g prebuildify node-gyp
- run: npm ci
- run: npm test
- run: npm run build
File renamed without changes.
2 changes: 1 addition & 1 deletion build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ npm run build

# build for linux/x64:
if [ ! -d prebuilds/linux-x64 ]; then
docker build -t voltserver/bcryptjs-linux-x64-builder .
docker build -t voltserver/bcryptjs-linux-x64-builder -f Dockerfile-x64 .
CONTAINER=$(docker create voltserver/bcryptjs-linux-x64-builder)
docker cp "$CONTAINER:/usr/local/opt/bcrypt-js/prebuilds" .
docker rm "$CONTAINER"
Expand Down

0 comments on commit 663bac5

Please sign in to comment.