Skip to content

feat: add OmniRoute vendored release workflow #2

feat: add OmniRoute vendored release workflow

feat: add OmniRoute vendored release workflow #2

name: Build OmniRoute artifacts
on:
workflow_dispatch:
inputs:
publish_to_azure:
description: Publish built artifacts to Azure Storage after all builds succeed
required: false
type: boolean
default: false
schedule:
- cron: "23 3 * * *"
push:
branches:
- main
paths:
- ".github/workflows/omniroute-artifacts.yaml"
- ".gitmodules"
- "README.md"
- "scripts/**"
- "packages/omniroute/**"
pull_request:
branches:
- main
paths:
- ".github/workflows/omniroute-artifacts.yaml"
- ".gitmodules"
- "README.md"
- "scripts/**"
- "packages/omniroute/**"
permissions:
contents: read
jobs:
prepare_release:
name: prepare-release
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 22
- name: Resolve release version
id: version
run: node ./scripts/versioning.mjs >> "$GITHUB_OUTPUT"
build:
name: ${{ matrix.name }}
needs: prepare_release
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- name: Linux x64
runner: ubuntu-22.04
artifact_name: omniroute-linux-amd64
platform: linux
arch: amd64
- name: macOS x64
runner: macos-13
artifact_name: omniroute-macos-amd64
platform: macos
arch: amd64
- name: macOS arm64
runner: macos-14
artifact_name: omniroute-macos-arm64
platform: macos
arch: arm64
- name: Windows x64
runner: windows-latest
artifact_name: omniroute-windows-amd64
platform: windows
arch: amd64
env:
CI: true
VERSION: ${{ needs.prepare_release.outputs.version }}
BUILD_ARTIFACTS_PLATFORM: ${{ matrix.platform }}
ARCH: ${{ matrix.arch }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
submodules: recursive
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
cache-dependency-path: packages/omniroute/upstream/package-lock.json
- name: Build artifacts
run: node ./packages/omniroute/scripts/build-artifacts.mjs
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: artifacts/omniroute/*
if-no-files-found: error
verify:
name: ${{ format('verify-{0}', matrix.name) }}
needs: build
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- name: Linux x64
runner: ubuntu-22.04
artifact_name: omniroute-linux-amd64
- name: macOS x64
runner: macos-13
artifact_name: omniroute-macos-amd64
- name: macOS arm64
runner: macos-14
artifact_name: omniroute-macos-arm64
- name: Windows x64
runner: windows-latest
artifact_name: omniroute-windows-amd64
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: packages/omniroute/upstream/.node-version
- name: Download artifacts
uses: actions/download-artifact@v5
with:
name: ${{ matrix.artifact_name }}
path: downloaded/omniroute
- name: Verify downloaded release
run: node ./packages/omniroute/scripts/verify-startup.mjs
publish_azure:
name: publish-azure
needs:
- prepare_release
- build
- verify
if: >-
${{
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.publish_to_azure == 'true')
}}
runs-on: ubuntu-22.04
concurrency:
group: vendered-azure-publication
cancel-in-progress: false
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 22
- name: Download build artifacts
uses: actions/download-artifact@v5
with:
pattern: omniroute-*
path: downloaded
- name: Validate Azure SAS secret
shell: bash
env:
AZURE_STORAGE_CONTAINER_SAS_URL: ${{ secrets.VENDORED_AZURE_CONTAINER_SAS_URL }}
run: |
if [[ -z "${AZURE_STORAGE_CONTAINER_SAS_URL}" ]]; then
echo "Missing GitHub secret: VENDORED_AZURE_CONTAINER_SAS_URL" >&2
exit 1
fi
- name: Publish vendored artifacts to Azure Storage
env:
AZURE_STORAGE_CONTAINER_SAS_URL: ${{ secrets.VENDORED_AZURE_CONTAINER_SAS_URL }}
run: node ./scripts/publish-to-azure.mjs --artifacts-dir downloaded --publish-result artifacts/publish-result.json
- name: Update version index
env:
AZURE_STORAGE_CONTAINER_SAS_URL: ${{ secrets.VENDORED_AZURE_CONTAINER_SAS_URL }}
run: node ./scripts/update-version-index.mjs --publish-result artifacts/publish-result.json
publish_github_release:
name: publish-github-release
needs:
- prepare_release
- build
- verify
if: >-
${{
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.publish_to_azure == 'true')
}}
runs-on: ubuntu-22.04
concurrency:
group: ${{ format('vendered-github-release-{0}', needs.prepare_release.outputs.tag) }}
cancel-in-progress: false
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 22
- name: Download build artifacts
uses: actions/download-artifact@v5
with:
pattern: omniroute-*
path: downloaded
- name: Create GitHub release and upload build archives
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
node ./scripts/github-release.mjs
--artifacts-dir downloaded
--tag "${{ needs.prepare_release.outputs.tag }}"
--name "${{ needs.prepare_release.outputs.version }}"
--target-commitish "${{ github.sha }}"