Skip to content

Publish Agent

Publish Agent #62

Workflow file for this run

name: Publish Agent
on:
workflow_dispatch:
inputs:
environment:
description: "Manual environment to run (staging | prod)"
required: false
type: string
agent_version:
description: "Build version example: v2.0.3"
required: true
type: string
permissions:
id-token: write # This is required for requesting the JWT
contents: write # This is required for actions/checkout
jobs:
### SET ENV ###
set_env:
runs-on: ubuntu-latest
name: Set Environment
steps:
- name: Set environment base on input
id: set_env
run: echo "Exposing environment vars to reusable workflow"
outputs:
ENV: ${{ inputs.environment }}
### BUILD ###
build:
name: Build
runs-on: ${{ matrix.os }}
env:
AGENT_VERSION: ${{ inputs.agent_version }}
strategy:
fail-fast: true
matrix:
os:
- ubuntu-22.04
- macos-13
- macos-14
- windows-2022
node-version:
- 20.9.0
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install packages
run: npm ci
- name: Set BUILD_VERSION environment variable
run: echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV
- name: Build with Node.js ${{ matrix.node-version }} on ${{ runner.os }}
env:
CI: true
if: ${{ matrix.os == 'ubuntu-22.04' }}
run: |
npm run build
node --experimental-sea-config sea-config.json
cp $(command -v node) agent
npx postject agent NODE_SEA_BLOB agent.blob \
--sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2
chmod +x agent
mkdir bin
mv agent bin/cli-linux-x64
npm run afterbuild
ls -al bin
- name: Build with Node.js ${{ matrix.node-version }} on ${{ runner.os }}
env:
CI: true
if: ${{ matrix.os == 'macos-13' }}
run: |
npm run build
node --experimental-sea-config sea-config.json
cp $(command -v node) agent
codesign --remove-signature agent
npx postject agent NODE_SEA_BLOB agent.blob \
--sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 \
--macho-segment-name NODE_SEA
# codesign --sign - agent
mkdir bin
chmod +x agent
mv agent bin/cli-macos-x64
npm run afterbuild
ls -al bin
- name: Build with Node.js ${{ matrix.node-version }} on ${{ runner.os }}
env:
CI: true
if: ${{ matrix.os == 'macos-14' }}
run: |
npm run build
node --experimental-sea-config sea-config.json
cp $(command -v node) agent
codesign --remove-signature agent
npx postject agent NODE_SEA_BLOB agent.blob \
--sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 \
--macho-segment-name NODE_SEA
# codesign --sign - agent
mkdir bin
chmod +x agent
mv agent bin/cli-macos-x64
npm run afterbuild
ls -al bin
- name: Build with Node.js ${{ matrix.node-version }} on ${{ runner.os }}
env:
CI: true
if: ${{ matrix.os == 'windows-2022' }}
run: |
npm run build
node --experimental-sea-config sea-config.json
node -e "require('fs').copyFileSync(process.execPath, 'agent.exe')"
# $signtool = "C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool\signtool.exe"
# $signtool remove /s agent.exe
npx postject agent.exe NODE_SEA_BLOB agent.blob `
--sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2
# $signtool sign /fd SHA256 agent.exe
# chmod +x agent
md bin -ea 0
cp agent.exe bin/cli-win-x64.exe
cp agent.exe bin/cli-win-x86.exe
npm run afterbuild
# ls -al
- name: Upload Windows x64 artifact
uses: actions/upload-artifact@v4
if: ${{ matrix.os == 'windows-2022' }}
with:
name: katalon-agent-win-x64-${{ env.AGENT_VERSION }}
path: |
bin/cli-win-x64.exe
bin/nssm.exe
bin/*.bat
- name: Upload Windows x86 artifact
uses: actions/upload-artifact@v4
if: ${{ matrix.os == 'windows-2022' }}
with:
name: katalon-agent-win-x86-${{ env.AGENT_VERSION }}
path: |
bin/cli-win-x86.exe
bin/nssm.exe
bin/*.bat
- name: Upload Linux x64 artifact
uses: actions/upload-artifact@v4
if: ${{ matrix.os == 'ubuntu-22.04' }}
with:
name: katalon-agent-linux-x64-${{ env.AGENT_VERSION }}
path: |
bin/cli-linux-x64
bin/*.sh
- name: Upload MacOS x64 artifact
uses: actions/upload-artifact@v4
if: ${{ matrix.os == 'macos-13' }}
with:
name: katalon-agent-macos-x64-${{ env.AGENT_VERSION }}
path: |
bin/cli-macos-x64
bin/start.sh
- name: Upload MacOS ARM64 artifact
uses: actions/upload-artifact@v4
if: ${{ matrix.os == 'macos-14' }}
with:
name: katalon-agent-macos-arm64-${{ env.AGENT_VERSION }}
path: |
bin/cli-macos-arm64
bin/start.sh
### RELEASE ###
release:
name: Release
environment: ${{ needs.set_env.outputs.ENV }}
env:
AGENT_VERSION: ${{ inputs.agent_version }}
needs: [set_env, build]
if: ${{ needs.set_env.outputs.ENV == 'prod' }}
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- 20.9.0
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install packages
run: npm ci
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: .
- name: Add execute permission to downloaded artifacts
run: chmod +x katalon-agent-linux-*/* katalon-agent-macos-*/*
- name: Set BUILD_VERSION environment variable
run: echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV
- name: Change Package.json version for release
run: sed -i "s/$BUILD_VERSION/$AGENT_VERSION/g" package.json
- name: Package artifacts for release
env:
GZIP: -9
run: |
set -x
mkdir -p packages
ls -la
zip -9 -j packages/katalon-agent-win-x64-$AGENT_VERSION.zip katalon-agent-win-x64-$AGENT_VERSION/*
zip -9 -j packages/katalon-agent-win-x86-$AGENT_VERSION.zip katalon-agent-win-x86-$AGENT_VERSION/*
zip -9 -j packages/katalon-agent-linux-x64-$AGENT_VERSION.zip katalon-agent-linux-x64-$AGENT_VERSION/*
zip -9 -j packages/katalon-agent-macos-x64-$AGENT_VERSION.zip katalon-agent-macos-x64-$AGENT_VERSION/*
zip -9 -j packages/katalon-agent-macos-arm64-$AGENT_VERSION.zip katalon-agent-macos-arm64-$AGENT_VERSION/*
cd katalon-agent-linux-x64-$AGENT_VERSION
tar cvzf ../packages/katalon-agent-linux-x64-$AGENT_VERSION.tar.gz *
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm run release
### DEPLOY ###
deploy:
name: Deploy cloud agent
environment: ${{ needs.set_env.outputs.ENV }}
env:
AGENT_VERSION: ${{ inputs.agent_version }}
needs: [set_env, build]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install packages
run: npm install --only dev
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/katalon-github-oidc-federation
role-session-name: github-actions
aws-region: ${{ vars.AWS_REGION }}
mask-aws-account-id: 'no'
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: .
- name: Add execute permission to downloaded artifacts
run: chmod +x katalon-agent-linux-*/* katalon-agent-macos-*/*
- name: Deploy to s3 prod
if: ${{ needs.set_env.outputs.ENV == 'prod' }}
run: |
ls -laR
aws s3 cp katalon-agent-linux-x64-*/cli-linux-x64 s3://${{ secrets.AWS_S3_BUCKET }}/katalon-agent/$AGENT_VERSION/cli-linux-x64
commit:
runs-on: ubuntu-latest
needs: [set_env, build, deploy, release]
name: Commit Code
env:
AGENT_VERSION: ${{ inputs.agent_version }}
environment: ${{ needs.set_env.outputs.ENV }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
- name: Set BUILD_VERSION environment variable
run: echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV
- name: Change Package.json version for release
run: sed -i "s/$BUILD_VERSION/$AGENT_VERSION/g" package.json
### Commit code
- name: Deploy to GitOps
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Update version to ${{ env.AGENT_VERSION }}
# Optional commit user and author settings
commit_user_name: github-cloudops-bot # defaults to "github-actions[bot]"
commit_user_email: [email protected] # defaults to "41898282+github-actions[bot]@users.noreply.github.com"
commit_author: Author <[email protected]> # defaults to author of the commit that triggered the run