Build and Upload native binaries #49
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Upload native binaries | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
env: | |
REGISTRY: ghcr.io | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
builder: | |
strategy: | |
fail-fast: true | |
matrix: | |
os: ['ubuntu-24.04', 'ubuntu-24.04-arm', 'macos-13', 'macos-15'] | |
runs-on: ${{ matrix.os }} | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: setup upx | |
run: | | |
wget https://github.com/upx/upx/releases/download/v5.0.1/upx-5.0.1-amd64_linux.tar.xz | |
tar -xvf upx-5.0.1-amd64_linux.tar.xz | |
chmod +x upx-5.0.1-amd64_linux/upx | |
sudo cp upx-5.0.1-amd64_linux/upx /usr/local/bin/ | |
if: matrix.os == 'ubuntu-24.04' | |
- name: setup upx | |
run: | | |
wget https://github.com/upx/upx/releases/download/v5.0.1/upx-5.0.1-arm64_linux.tar.xz | |
tar -xvf upx-5.0.1-arm64_linux.tar.xz | |
chmod +x upx-5.0.1-arm64_linux/upx | |
sudo cp upx-5.0.1-arm64_linux/upx /usr/local/bin/ | |
if: matrix.os == 'ubuntu-24.04-arm' | |
- name: Setup swift | |
if: matrix.os == 'ubuntu-24.04' || matrix.os == 'ubuntu-24.04-arm' | |
run: | | |
curl -O https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz && \ | |
tar zxf swiftly-$(uname -m).tar.gz && \ | |
./swiftly init --quiet-shell-followup && \ | |
. ~/.local/share/swiftly/env.sh && \ | |
hash -r | |
- name: Setup swift | |
if: matrix.os == 'macos-15' | |
run: | | |
curl -O https://download.swift.org/swiftly/darwin/swiftly.pkg && \ | |
installer -pkg swiftly.pkg -target CurrentUserHomeDirectory && \ | |
~/.swiftly/bin/swiftly init --quiet-shell-followup && \ | |
. ~/.swiftly/env.sh && \ | |
hash -r | |
- uses: oras-project/setup-oras@v1 | |
- run: oras version | |
- name: Build | |
run: | | |
bash thirdparty/sourcekitten/build.sh | |
ls -al thirdparty/sourcekitten/SourceKitten/.build | |
ls -l thirdparty/sourcekitten/SourceKitten/.build/release | |
echo $GITHUB_TOKEN | oras login ghcr.io -u $GITHUB_USERNAME --password-stdin | |
env: | |
GITHUB_USERNAME: ${{ github.actor }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload linux amd64 | |
run: | | |
pushd thirdparty/trivy | |
make build/linuxmusl_amd64 | |
upx -9 --lzma ./build/trivy-cdxgen-linuxmusl-amd64 | |
popd | |
sudo chown -R $USER:$USER thirdparty/trivy/build/ | |
mkdir -p uploads | |
cp thirdparty/trivy/build/trivy* uploads/ | |
cp thirdparty/sourcekitten/SourceKitten/.build/release/sourcekitten uploads/ | |
cp thirdparty/sourcekitten/SourceKitten/.build/release/sourcekitten.sha256 uploads/ | |
cd uploads | |
oras push ghcr.io/cyclonedx/cdxgen-plugins-bin:linux-amd64 \ | |
--artifact-type application/vnd.oras.config.v1+json \ | |
./trivy-cdxgen-linuxmusl-amd64:application/vnd.cyclonedx.plugins.layer.v1+tar \ | |
./trivy-cdxgen-linuxmusl-amd64.sha256:application/vnd.cyclonedx.plugins.layer.v1+tar \ | |
./sourcekitten:application/vnd.cyclonedx.plugins.layer.v1+tar \ | |
./sourcekitten.sha256:application/vnd.cyclonedx.plugins.layer.v1+tar | |
if: matrix.os == 'ubuntu-24.04' | |
- name: Upload linux arm64 | |
run: | | |
pushd thirdparty/trivy | |
make build/linuxmusl_arm64 | |
upx -9 --lzma ./build/trivy-cdxgen-linuxmusl-arm64 | |
popd | |
sudo chown -R $USER:$USER thirdparty/trivy/build/ | |
mkdir -p uploads | |
cp thirdparty/trivy/build/trivy* uploads/ | |
cp thirdparty/sourcekitten/SourceKitten/.build/release/sourcekitten uploads/ | |
cp thirdparty/sourcekitten/SourceKitten/.build/release/sourcekitten.sha256 uploads/ | |
cd uploads | |
oras push ghcr.io/cyclonedx/cdxgen-plugins-bin:linux-arm64 \ | |
--artifact-type application/vnd.oras.config.v1+json \ | |
./trivy-cdxgen-linuxmusl-arm64:application/vnd.cyclonedx.plugins.layer.v1+tar \ | |
./trivy-cdxgen-linuxmusl-arm64.sha256:application/vnd.cyclonedx.plugins.layer.v1+tar \ | |
./sourcekitten:application/vnd.cyclonedx.plugins.layer.v1+tar \ | |
./sourcekitten.sha256:application/vnd.cyclonedx.plugins.layer.v1+tar | |
if: matrix.os == 'ubuntu-24.04-arm' | |
- name: Upload darwin amd64 | |
run: | | |
cd thirdparty/sourcekitten/SourceKitten/.build/release/ | |
oras push ghcr.io/cyclonedx/cdxgen-plugins-bin:darwin-amd64 \ | |
--artifact-type application/vnd.oras.config.v1+json \ | |
./sourcekitten:application/vnd.cyclonedx.plugins.layer.v1+tar \ | |
./sourcekitten.sha256:application/vnd.cyclonedx.plugins.layer.v1+tar | |
if: matrix.os == 'macos-13' | |
- name: Upload darwin arm64 | |
run: | | |
cd thirdparty/sourcekitten/SourceKitten/.build/release/ | |
oras push ghcr.io/cyclonedx/cdxgen-plugins-bin:darwin-arm64 \ | |
--artifact-type application/vnd.oras.config.v1+json \ | |
./sourcekitten:application/vnd.cyclonedx.plugins.layer.v1+tar \ | |
./sourcekitten.sha256:application/vnd.cyclonedx.plugins.layer.v1+tar | |
if: matrix.os == 'macos-15' |