Skip to content

chore(chrome-extension): move chrome-extension workflow into release … #27

chore(chrome-extension): move chrome-extension workflow into release …

chore(chrome-extension): move chrome-extension workflow into release … #27

Workflow file for this run

name: Release
on:
workflow_dispatch:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
build-binary:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: linux-x86_64
rust_target: x86_64-unknown-linux-musl
goos: linux
goarch: amd64
exe_ext: ""
cross: false
build_dir: target
- os: ubuntu-latest
target: linux-arm64
rust_target: aarch64-unknown-linux-musl
goos: linux
goarch: arm64
exe_ext: ""
cross: true
build_dir: target-cross
- os: windows-latest
target: windows-x86_64
rust_target: x86_64-pc-windows-msvc
goos: windows
goarch: amd64
exe_ext: ".exe"
cross: false
build_dir: target
- os: macos-15-intel
target: macos-x86_64
rust_target: x86_64-apple-darwin
goos: darwin
goarch: amd64
exe_ext: ""
cross: false
build_dir: target
- os: macos-latest
target: macos-arm64
rust_target: aarch64-apple-darwin
goos: darwin
goarch: arm64
exe_ext: ""
cross: false
build_dir: target
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Linux build dependencies
if: ${{ runner.os == 'Linux' && !contains(matrix.rust_target, 'linux-musl') }}
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends -o Acquire::Retries=3 libasound2-dev
- name: Install musl tools (Linux)
if: ${{ contains(matrix.rust_target, 'linux-musl') && !matrix.cross }}
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends -o Acquire::Retries=3 musl-tools libasound2-dev linux-libc-dev
- name: Install cross (ARM Linux)
if: ${{ matrix.cross }}
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.rust_target }}
- uses: Swatinem/rust-cache@v2
if: ${{ !matrix.cross }}
- name: Build Rust binary (native)
if: ${{ !matrix.cross }}
run: |
cargo build --release --locked --target ${{ matrix.rust_target }}
- name: Build Rust binary (cross)
if: ${{ matrix.cross }}
run: |
cross build --release --locked --target-dir ${{ matrix.build_dir }} --target ${{ matrix.rust_target }}
- name: Collect artifacts
shell: bash
run: |
mkdir -p release
cp "${{ matrix.build_dir }}/${{ matrix.rust_target }}/release/anda${{ matrix.exe_ext }}" "release/anda-${{ matrix.target }}${{ matrix.exe_ext }}"
for file in release/*; do
if command -v sha256sum >/dev/null 2>&1; then
hash="$(sha256sum "$file" | awk '{print $1}')"
elif command -v shasum >/dev/null 2>&1; then
hash="$(shasum -a 256 "$file" | awk '{print $1}')"
else
hash="$(openssl dgst -sha256 "$file" | awk '{print $NF}')"
fi
echo "$hash $(basename "$file")" > "${file}.sha256"
done
ls -lah release
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.target }}
path: release/*
if-no-files-found: error
package-skills:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Package skills
shell: bash
run: |
mkdir -p release
skills_archive="anda-skills.zip"
(cd skills && zip -qr "../release/${skills_archive}" . -x '__pycache__/*' '*/__pycache__/*' '*.pyc' '.DS_Store' '*/.DS_Store')
hash="$(sha256sum "release/${skills_archive}" | awk '{print $1}')"
echo "$hash ${skills_archive}" > "release/${skills_archive}.sha256"
ls -lah release
- name: Upload skills artifact
uses: actions/upload-artifact@v4
with:
name: release-skills
path: release/*
if-no-files-found: error
chrome-extension:
needs: build-binary
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: npm install -g pnpm
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build extension
run: pnpm --dir chrome-extension build
- name: zip extension
id: pack
uses: cardinalby/webext-buildtools-pack-extension-dir-action@v1
with:
extensionDir: chrome-extension/dist
zipFilePath: release/anda-bot-chrome-extension.zip
- name: sign CRX
uses: cardinalby/webext-buildtools-chrome-crx-action@v2
with:
zipFilePath: release/anda-bot-chrome-extension.zip
crxFilePath: release/anda-bot-chrome-extension.crx
privateKey: ${{ secrets.CHROME_CRX_PRIVATE_KEY }}
- name: Upload Chrome extension artifact
uses: actions/upload-artifact@v4
with:
name: release-chrome-extension
path: release/*
if-no-files-found: error
release:
needs:
- build-binary
- package-skills
- chrome-extension
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: release-*
merge-multiple: true
path: release
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
files: release/*