Skip to content

Commit

Permalink
Clean up GitHub Actions workflows
Browse files Browse the repository at this point in the history
- Reorganize in to matrix builds for less redundancy
- Use IBM approved actions
  • Loading branch information
kadler committed Aug 20, 2024
1 parent 1b6f05d commit d2a737b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 254 deletions.
49 changes: 9 additions & 40 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,24 @@ name: Build
on: pull_request

jobs:
build-windows:

runs-on: windows-latest

strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Build package
run: npm ci --production --build-from-source

build-ubuntu:

runs-on: ubuntu-latest

build-matrix:
strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Build package
run: npm ci --production --build-from-source

build-macos:

runs-on: macos-latest

strategy:
matrix:
node-version: [18.x]

node-version:
- 18.x
os:
- windows-latest
- ubuntu-latest
- macos-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
if: ${{ startsWith(matrix.os, 'macos') }}
run: brew install unixodbc
- name: Build package
run: npm ci --production --build-from-source
236 changes: 22 additions & 214 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ on:
tags: ["v*"]

jobs:
build-windows:

runs-on: windows-latest

build-matrix:
strategy:
matrix:
node-version: [18.x]

node-version:
- 18.x
os:
- windows-latest
- ubuntu-latest
- macos-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
Expand All @@ -25,232 +27,38 @@ jobs:
run: npm install -g node-gyp
- name: Install npm dependencies
run: npm ci --production
- name: Build Binary
run: ./node_modules/.bin/node-pre-gyp rebuild --production
- name: Package Binary
run: ./node_modules/.bin/node-pre-gyp package
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: windows-binaries
path: build/stage/*.tar.gz

build-macos:

runs-on: macos-latest

strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
if: ${{ startsWith(matrix.os, 'macos') }}
run: brew install unixodbc
- name: Upgrade NPM
run: npm install -g npm
- name: Install node-gyp
run: npm install -g node-gyp
- name: Install npm dependencies
run: npm ci --production
- name: Build Binary
run: ./node_modules/.bin/node-pre-gyp rebuild --production
- name: Package Binary
run: ./node_modules/.bin/node-pre-gyp package
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: macos-binaries
path: build/stage/*.tar.gz

build-linux:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Upgrade NPM
run: npm install -g npm
- name: Install node-gyp
run: npm install -g node-gyp
- name: Install npm dependencies
run: npm ci --production
- name: Build Binary
run: ./node_modules/.bin/node-pre-gyp rebuild --production
- name: Package Binary
run: ./node_modules/.bin/node-pre-gyp package
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: linux-binaries
name: ${{ matrix.os }}-binaries
path: build/stage/*.tar.gz

create-release:

runs-on: ubuntu-latest

needs: [build-windows, build-macos, build-linux]

needs: build-matrix
steps:

- uses: actions/checkout@v2

- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@master

run: jq -r '"version=" + .version' package.json >> "$GITHUB_OUTPUT"
# Download all of the various binaries that were created
- name: Download built binaries from workflow
uses: actions/download-artifact@v3
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.package-version.outputs.current-version }}
release_name: ${{ steps.package-version.outputs.current-version }}
draft: true
draft: false
prerelease: false


# Download all of the various binaries that were created
- uses: actions/download-artifact@v3

# There is no 'upload-release-artifact' package that currently allows
# uploading to a draft release, other than the GitHub action that is no
# longer supported. However, that package allows only uploading one file
# at a time. Bit the bullet for now, contribute to one of the other projects
# later

# Windows binaries
- name: Upload odbc-v${{ steps.package-version.outputs.current-version }}-win32-x64-napi-v3.tar.gz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./windows-binaries/odbc-v${{ steps.package-version.outputs.current-version }}-win32-x64-napi-v3.tar.gz
asset_name: odbc-v${{ steps.package-version.outputs.current-version }}-win32-x64-napi-v3.tar.gz
asset_content_type: application/gzip

- name: Upload odbc-v${{ steps.package-version.outputs.current-version }}-win32-x64-napi-v4.tar.gz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./windows-binaries/odbc-v${{ steps.package-version.outputs.current-version }}-win32-x64-napi-v4.tar.gz
asset_name: odbc-v${{ steps.package-version.outputs.current-version }}-win32-x64-napi-v4.tar.gz
asset_content_type: application/gzip

- name: Upload odbc-v${{ steps.package-version.outputs.current-version }}-win32-x64-napi-v5.tar.gz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./windows-binaries/odbc-v${{ steps.package-version.outputs.current-version }}-win32-x64-napi-v5.tar.gz
asset_name: odbc-v${{ steps.package-version.outputs.current-version }}-win32-x64-napi-v5.tar.gz
asset_content_type: application/gzip

- name: Upload odbc-v${{ steps.package-version.outputs.current-version }}-win32-x64-napi-v6.tar.gz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./windows-binaries/odbc-v${{ steps.package-version.outputs.current-version }}-win32-x64-napi-v6.tar.gz
asset_name: odbc-v${{ steps.package-version.outputs.current-version }}-win32-x64-napi-v6.tar.gz
asset_content_type: application/gzip

# Macos binaries
- name: Upload odbc-v${{ steps.package-version.outputs.current-version }}-darwin-x64-napi-v3.tar.gz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./macos-binaries/odbc-v${{ steps.package-version.outputs.current-version }}-darwin-x64-napi-v3.tar.gz
asset_name: odbc-v${{ steps.package-version.outputs.current-version }}-darwin-x64-napi-v3.tar.gz
asset_content_type: application/gzip

- name: Upload odbc-v${{ steps.package-version.outputs.current-version }}-darwin-x64-napi-v4.tar.gz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./macos-binaries/odbc-v${{ steps.package-version.outputs.current-version }}-darwin-x64-napi-v4.tar.gz
asset_name: odbc-v${{ steps.package-version.outputs.current-version }}-darwin-x64-napi-v4.tar.gz
asset_content_type: application/gzip

- name: Upload odbc-v${{ steps.package-version.outputs.current-version }}-darwin-x64-napi-v5.tar.gz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./macos-binaries/odbc-v${{ steps.package-version.outputs.current-version }}-darwin-x64-napi-v5.tar.gz
asset_name: odbc-v${{ steps.package-version.outputs.current-version }}-darwin-x64-napi-v5.tar.gz
asset_content_type: application/gzip

- name: Upload odbc-v${{ steps.package-version.outputs.current-version }}-darwin-x64-napi-v6.tar.gz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./macos-binaries/odbc-v${{ steps.package-version.outputs.current-version }}-darwin-x64-napi-v6.tar.gz
asset_name: odbc-v${{ steps.package-version.outputs.current-version }}-darwin-x64-napi-v6.tar.gz
asset_content_type: application/gzip

# Linux binaries
- name: Upload odbc-v${{ steps.package-version.outputs.current-version }}-linux-x64-napi-v3.tar.gz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./linux-binaries/odbc-v${{ steps.package-version.outputs.current-version }}-linux-x64-napi-v3.tar.gz
asset_name: odbc-v${{ steps.package-version.outputs.current-version }}-linux-x64-napi-v3.tar.gz
asset_content_type: application/gzip

- name: Upload odbc-v${{ steps.package-version.outputs.current-version }}-linux-x64-napi-v4.tar.gz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./linux-binaries/odbc-v${{ steps.package-version.outputs.current-version }}-linux-x64-napi-v4.tar.gz
asset_name: odbc-v${{ steps.package-version.outputs.current-version }}-linux-x64-napi-v4.tar.gz
asset_content_type: application/gzip

- name: Upload odbc-v${{ steps.package-version.outputs.current-version }}-linux-x64-napi-v5.tar.gz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./linux-binaries/odbc-v${{ steps.package-version.outputs.current-version }}-linux-x64-napi-v5.tar.gz
asset_name: odbc-v${{ steps.package-version.outputs.current-version }}-linux-x64-napi-v5.tar.gz
asset_content_type: application/gzip

- name: Upload odbc-v${{ steps.package-version.outputs.current-version }}-linux-x64-napi-v6.tar.gz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./linux-binaries/odbc-v${{ steps.package-version.outputs.current-version }}-linux-x64-napi-v6.tar.gz
asset_name: odbc-v${{ steps.package-version.outputs.current-version }}-linux-x64-napi-v6.tar.gz
asset_content_type: application/gzip
name: ${{ steps.package-version.outputs.version }}
generate_release_notes: true
fail_on_unmatched_files: true
files:
./*-binaries/odbc-*.tar.gz

0 comments on commit d2a737b

Please sign in to comment.