Skip to content

fix stack comments + README audit #7

fix stack comments + README audit

fix stack comments + README audit #7

Workflow file for this run

name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
id-token: write
env:
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
# macOS
- os: macos-latest
target: x86_64-apple-darwin
platform: darwin-x64
- os: macos-latest
target: aarch64-apple-darwin
platform: darwin-arm64
# Linux glibc
- os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
platform: linux-x64
- os: ubuntu-22.04
target: aarch64-unknown-linux-gnu
platform: linux-arm64
cross: true
# Linux musl (use cross for both - handles OpenSSL)
- os: ubuntu-22.04
target: x86_64-unknown-linux-musl
platform: linux-x64-musl
cross: true
- os: ubuntu-22.04
target: aarch64-unknown-linux-musl
platform: linux-arm64-musl
cross: true
# Windows
- os: windows-latest
target: x86_64-pc-windows-msvc
platform: win32-x64
- os: windows-latest
target: aarch64-pc-windows-msvc
platform: win32-arm64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross
if: matrix.cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Build (cross)
if: matrix.cross
run: cross build --release --target ${{ matrix.target }}
env:
RUSTFLAGS: "-C strip=symbols"
- name: Build (native)
if: "!matrix.cross"
run: cargo build --release --target ${{ matrix.target }}
env:
RUSTFLAGS: "-C strip=symbols"
- name: Prepare artifact (Unix)
if: runner.os != 'Windows'
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/ryu dist/
chmod +x dist/ryu
- name: Sign binary (macOS)
if: runner.os == 'macOS'
run: codesign --force --sign - dist/ryu
- name: Prepare artifact (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path dist
Copy-Item "target/${{ matrix.target }}/release/ryu.exe" -Destination "dist/"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform }}
path: dist/
if-no-files-found: error
# Create GitHub release with binaries
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create release archives
run: |
mkdir -p release
for platform in artifacts/*/; do
name=$(basename "$platform")
if [[ "$name" == win32-* ]]; then
(cd "$platform" && zip -r "../../release/ryu-${name}.zip" .)
else
(cd "$platform" && tar -czvf "../../release/ryu-${name}.tar.gz" .)
fi
done
ls -la release/
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: release/*
generate_release_notes: true
# Publish to npm
publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Get version from tag
id: version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Prepare platform packages
run: |
VERSION=${{ steps.version.outputs.version }}
# Generate package.json and copy binary for each platform
for platform in darwin-arm64 darwin-x64 linux-arm64 linux-x64 linux-arm64-musl linux-x64-musl win32-arm64 win32-x64; do
mkdir -p npm/$platform
# Copy binary
if [[ "$platform" == win32-* ]]; then
cp artifacts/$platform/ryu.exe npm/$platform/
else
cp artifacts/$platform/ryu npm/$platform/
chmod +x npm/$platform/ryu
fi
# Generate package.json
node npm/scripts/generate-platform-package.mjs $platform $VERSION
done
- name: Update main package version
run: |
VERSION=${{ steps.version.outputs.version }}
cd npm/jj-ryu
# Update version and optionalDependencies versions
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
pkg.version = '$VERSION';
for (const dep of Object.keys(pkg.optionalDependencies)) {
pkg.optionalDependencies[dep] = '$VERSION';
}
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
"
- name: Publish platform packages
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
for platform in darwin-arm64 darwin-x64 linux-arm64 linux-x64 linux-arm64-musl linux-x64-musl win32-arm64 win32-x64; do
echo "Publishing @jj-ryu/$platform..."
npm publish npm/$platform --access public --provenance
done
- name: Publish main package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
echo "Publishing jj-ryu..."
npm publish npm/jj-ryu --access public --provenance
# Publish to crates.io
publish-crates:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}