Skip to content

feat: add binary release action.#274

Merged
genedna merged 5 commits into
libra-tools:mainfrom
erasernoob:main
Mar 10, 2026
Merged

feat: add binary release action.#274
genedna merged 5 commits into
libra-tools:mainfrom
erasernoob:main

Conversation

@erasernoob

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread .github/workflows/release.yml Fixed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bd62162c53

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread .github/workflows/release.yml
Comment thread .github/workflows/release.yml
Comment on lines +14 to +142
runs-on: ${{ matrix.target.runner }}
strategy:
fail-fast: false
fail-fast: true # if it is set to true, then one job failed the other jobs will be cancelled together.
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
archive_ext: tar.gz
bin_ext: ""
- os: macos-latest
target: aarch64-apple-darwin
archive_ext: tar.gz
bin_ext: ""
- os: windows-latest
target: x86_64-pc-windows-msvc
archive_ext: zip
bin_ext: .exe

runs-on: ${{ matrix.os }}
component: [libra]
target:
- { rust: x86_64-unknown-linux-gnu, os: linux, arch: amd64, runner: ubuntu-latest }
- { rust: aarch64-unknown-linux-gnu, os: linux, arch: arm64, runner: ubuntu-24.04-arm }
- { rust: aarch64-apple-darwin, os: darwin, arch: arm64, runner: macos-latest }
- { rust: x86_64-pc-windows-msvc, os: windows, arch: amd64, runner: windows-latest }

steps:
- name: Checkout
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive

- name: Resolve tag
id: meta
shell: bash
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target.rust }}

- name: Install Linux dependencies
if: matrix.target.os == 'linux'
run: |
sudo apt-get update

- name: Install macOS dependencies
if: matrix.target.os == 'darwin'
run: |
if [ "${{ github.event_name }}" = "release" ]; then
echo "tag=${{ github.event.release.tag_name }}" >> "$GITHUB_OUTPUT"
else
echo "tag=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
fi

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
targets: ${{ matrix.target }}
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Cache cargo index
uses: actions/cache@v4
with:
key: ${{ matrix.target }}
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}

- name: Build
shell: bash
run: cargo build --locked --release --target ${{ matrix.target }}
- name: Cache cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ matrix.target.rust }}-${{ hashFiles('**/Cargo.lock') }}

- name: Prepare package (Unix)
if: runner.os != 'Windows'
- name: Build Binary (Unix)
if: matrix.target.os != 'windows'
shell: bash
run: |
set -euxo pipefail
VERSION=${GITHUB_REF_NAME}
BINARY_NAME="${{ matrix.component }}-${{ matrix.target.os }}-${{ matrix.target.arch }}"

echo "Building $BINARY_NAME for target ${{ matrix.target.rust }}..."

RUSTFLAGS="-C strip=symbols" cargo build --locked --release --target ${{ matrix.target.rust }}

TAG="${{ steps.meta.outputs.tag }}"
PKG="${BIN_NAME}_${TAG}_${{ matrix.target }}"
mkdir -p dist/$PKG
# Create build directory and copy binary
mkdir -p build
cp target/${{ matrix.target.rust }}/release/${{ matrix.component }} build/$BINARY_NAME

cp "target/${{ matrix.target }}/release/${BIN_NAME}" "dist/$PKG/${BIN_NAME}"
cp README.md "dist/$PKG/" || true
cp LICENSE* "dist/$PKG/" 2>/dev/null || true
# Make binary executable
chmod +x build/$BINARY_NAME

tar -C dist -czf "dist/${PKG}.tar.gz" "$PKG"
shasum -a 256 "dist/${PKG}.tar.gz" > "dist/${PKG}.tar.gz.sha256"
echo "Built binary: $BINARY_NAME"

- name: Prepare package (Windows)
if: runner.os == 'Windows'
- name: Build Binary (Windows)
if: matrix.target.os == 'windows'
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
$version = $env:GITHUB_REF_NAME
$binaryName = "${{ matrix.component }}-${{ matrix.target.os }}-${{ matrix.target.arch }}"

$tag = "${{ steps.meta.outputs.tag }}"
$pkg = "${env:BIN_NAME}_${tag}_${{ matrix.target }}"
New-Item -ItemType Directory -Force -Path "dist\$pkg" | Out-Null
Write-Output "Building $binaryName for target ${{ matrix.target.rust }}..."

Copy-Item "target\${{ matrix.target }}\release\${env:BIN_NAME}${{ matrix.bin_ext }}" "dist\$pkg\${env:BIN_NAME}${{ matrix.bin_ext }}"
if (Test-Path "README.md") { Copy-Item "README.md" "dist\$pkg\" }
Get-ChildItem "LICENSE*" -ErrorAction SilentlyContinue | ForEach-Object {
Copy-Item $_.FullName "dist\$pkg\"
}
$env:RUSTFLAGS = "-C strip=symbols"
cargo build --locked --release --target ${{ matrix.target.rust }}

Compress-Archive -Path "dist\$pkg\*" -DestinationPath "dist\$pkg.zip" -Force
# Create build directory and copy binary
New-Item -ItemType Directory -Force -Path "build" | Out-Null
Copy-Item "target\${{ matrix.target.rust }}\release\${{ matrix.component }}.exe" "build\$binaryName.exe"

$hash = (Get-FileHash "dist\$pkg.zip" -Algorithm SHA256).Hash.ToLower()
"$hash $pkg.zip" | Out-File -Encoding ascii "dist\$pkg.zip.sha256"
Write-Output "Built binary: $binaryName"

- name: Upload packaged artifact
uses: actions/upload-artifact@v4
with:
name: package-${{ matrix.target }}
path: dist/*
if-no-files-found: error
retention-days: 7
- name: Upload to Cloudflare R2 (Unix)
if: matrix.target.os != 'windows'
shell: bash
env:
RCLONE_CONFIG_R2_TYPE: s3
RCLONE_CONFIG_R2_PROVIDER: Cloudflare
RCLONE_CONFIG_R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
RCLONE_CONFIG_R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
RCLONE_CONFIG_R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }}
RCLONE_CONFIG_R2_ACL: private
run: |
# Install rclone
if [[ "${{ matrix.target.os }}" == "darwin" ]]; then
brew install rclone
else
curl https://rclone.org/install.sh | sudo bash
fi

publish-draft-assets:
name: Upload assets to draft release
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.release.draft == true
# Upload binaries to R2
rclone copy ./build/ r2:${{ secrets.R2_BUCKET_NAME }}/libra/releases/${{ github.ref_name }}/ -v

steps:
- name: Download all build artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
echo "Upload completed for ${{ matrix.component }}-${{ matrix.target.os }}-${{ matrix.target.arch }}"

- name: Merge checksums
shell: bash
- name: Upload to Cloudflare R2 (Windows)
if: matrix.target.os == 'windows'
shell: pwsh
env:
RCLONE_CONFIG_R2_TYPE: s3
RCLONE_CONFIG_R2_PROVIDER: Cloudflare
RCLONE_CONFIG_R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
RCLONE_CONFIG_R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
RCLONE_CONFIG_R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }}
RCLONE_CONFIG_R2_ACL: private
run: |
set -euxo pipefail
find artifacts -type f -name '*.sha256' -print0 | sort -z | xargs -0 cat > checksums.txt
ls -R artifacts
cat checksums.txt
# Install rclone via choco
choco install rclone -y

- name: Upload assets to GitHub Draft Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.release.tag_name }}
overwrite_files: true
fail_on_unmatched_files: true
files: |
artifacts/**/*
checksums.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Upload binaries to R2
rclone copy ./build/ r2:${{ secrets.R2_BUCKET_NAME }}/libra/releases/${{ github.ref_name }}/ -v

Write-Output "Upload completed for ${{ matrix.component }}-${{ matrix.target.os }}-${{ matrix.target.arch }}"

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e43f616f84

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread .github/workflows/release.yml
Comment thread .github/workflows/release.yml Fixed
@genedna
genedna merged commit 40847f5 into libra-tools:main Mar 10, 2026
3 checks passed
genedna pushed a commit to genedna/libra that referenced this pull request Mar 15, 2026
* feat: implement release action

* add pull request main branch

* fix: windows issue

* set false to test

* rm test code line
genedna pushed a commit to genedna/libra that referenced this pull request Mar 17, 2026
* feat: implement release action

* add pull request main branch

* fix: windows issue

* set false to test

* rm test code line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants