utoopack-v1.5.12 #542
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: utoopm-release | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Version string (e.g. 0.0.0-test)" | |
| required: false | |
| default: "0.0.0-dev" | |
| jobs: | |
| build-and-publish-binary: | |
| if: github.event_name == 'workflow_dispatch' || startsWith(github.event.release.tag_name, 'utoo-') | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| platform_os: linux | |
| platform_cpu: x64 | |
| container: ubuntu:20.04 | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| platform_os: darwin | |
| platform_cpu: x64 | |
| - os: macos-latest | |
| target: aarch64-apple-darwin | |
| platform_os: darwin | |
| platform_cpu: arm64 | |
| - os: ubuntu-22.04-arm | |
| target: aarch64-unknown-linux-gnu | |
| platform_os: linux | |
| platform_cpu: arm64 | |
| container: ubuntu:20.04 | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| platform_os: win32 | |
| platform_cpu: x64 | |
| runs-on: ${{ matrix.os }} | |
| container: | |
| image: ${{ matrix.container }} | |
| defaults: | |
| run: | |
| shell: bash | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - name: Install Linux Dependencies | |
| if: ${{ matrix.platform_os == 'linux' }} | |
| timeout-minutes: 10 | |
| env: | |
| DEBIAN_FRONTEND: noninteractive | |
| # Short per-apt timeouts: on GHA runners that can't route to | |
| # archive/security.ubuntu.com, apt otherwise sits in 90s × 8-IP SYN | |
| # timeouts. Bail after 60s on the default mirror, swap to the | |
| # Fastly-backed kernel.org mirror, and retry once. | |
| # | |
| # If the first attempt times out mid-unpack (e.g. libc6 upgrade), | |
| # dpkg is left half-configured and the retry fails with | |
| # "dpkg was interrupted". `dpkg --configure -a` finalises any | |
| # pending unpack before we retry on the fallback mirror. | |
| run: | | |
| install_pkgs() { | |
| timeout 60 apt-get update \ | |
| && timeout 180 apt-get install -y \ | |
| build-essential \ | |
| libc6-dev \ | |
| libglib2.0-0 \ | |
| curl \ | |
| tzdata \ | |
| pkg-config \ | |
| gnupg2 \ | |
| software-properties-common \ | |
| git | |
| } | |
| if ! install_pkgs; then | |
| echo "apt default mirror failed/timed out, falling back to mirrors.edge.kernel.org" | |
| dpkg --configure -a || true | |
| sed -i 's|http://archive\.ubuntu\.com|http://mirrors.edge.kernel.org|g; s|http://security\.ubuntu\.com|http://mirrors.edge.kernel.org|g' /etc/apt/sources.list | |
| install_pkgs | |
| fi | |
| curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg | |
| chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg | |
| echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null | |
| apt-get update && apt-get install -y gh | |
| - uses: actions/checkout@v6 | |
| - name: Configure git safe directory | |
| run: | | |
| git config --global --add safe.directory /__w/utoo/utoo | |
| - name: Get version and npm tag from release | |
| id: get_version | |
| run: | | |
| if [[ "$GITHUB_REF" == refs/tags/utoo-v* ]]; then | |
| VERSION="${GITHUB_REF#refs/tags/utoo-v}" | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Extracted version: $VERSION" | |
| else | |
| VERSION="${{ github.event.inputs.version || '0.0.0-dev' }}" | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Using version: $VERSION" | |
| fi | |
| if [[ "$VERSION" == *"-"* ]]; then | |
| PRERELEASE="${VERSION#*-}" | |
| NPM_TAG="${PRERELEASE%%.*}" | |
| elif [[ "${{ github.event_name }}" == "release" && "${{ github.event.release.prerelease }}" == "true" ]]; then | |
| NPM_TAG="beta" | |
| else | |
| NPM_TAG="latest" | |
| fi | |
| echo "NPM_TAG=$NPM_TAG" >> $GITHUB_OUTPUT | |
| echo "Using npm tag: $NPM_TAG" | |
| - name: Update Cargo.toml version | |
| env: | |
| VERSION: ${{ steps.get_version.outputs.VERSION }} | |
| run: | | |
| set -euo pipefail | |
| awk -v ver="$VERSION" ' | |
| !done && /^version[[:space:]]*=/ { print "version = \"" ver "\""; done=1; next } | |
| { print } | |
| ' crates/pm/Cargo.toml > crates/pm/Cargo.toml.tmp | |
| mv crates/pm/Cargo.toml.tmp crates/pm/Cargo.toml | |
| ACTUAL=$(awk -F\" '/^version[[:space:]]*=/ { print $2; exit }' crates/pm/Cargo.toml) | |
| if [ "$ACTUAL" != "$VERSION" ]; then | |
| echo "Failed to update crates/pm/Cargo.toml to version $VERSION; found $ACTUAL" >&2 | |
| head -12 crates/pm/Cargo.toml >&2 | |
| exit 1 | |
| fi | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: nightly-2026-07-29 | |
| targets: ${{ matrix.target }} | |
| # - name: Cache cargo | |
| # uses: Swatinem/rust-cache@v2 | |
| # with: | |
| # shared-key: pm-release-${{ matrix.target }} | |
| - name: Add cross-compilation target for x86_64 on macOS | |
| if: ${{ matrix.target == 'x86_64-apple-darwin' }} | |
| run: rustup target add x86_64-apple-darwin | |
| - name: Init git submodules | |
| run: git submodule update --init --recursive --depth 1 | |
| - name: Build | |
| run: cargo build --release --bin utoo --target ${{ matrix.target }} -p utoo-pm | |
| - name: Package Binaries | |
| run: | | |
| cd target/${{ matrix.target }}/release | |
| if [ "${{ matrix.platform_os }}" = "win32" ]; then | |
| tar -czf ../../../utoo-${{ matrix.platform_os }}-${{ matrix.platform_cpu }}.tar.gz utoo.exe | |
| else | |
| tar -czf ../../../utoo-${{ matrix.platform_os }}-${{ matrix.platform_cpu }}.tar.gz utoo | |
| fi | |
| shell: bash | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: utoo-${{ matrix.platform_os }}-${{ matrix.platform_cpu }} | |
| path: utoo-${{ matrix.platform_os }}-${{ matrix.platform_cpu }}.tar.gz | |
| retention-days: 7 | |
| - name: Setup Node.js | |
| if: ${{ github.event_name == 'release' }} | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22.14.0 | |
| package-manager-cache: false | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Bump npm CLI for OIDC trusted publisher | |
| # Trusted publishing requires npm 11.5.1+. | |
| if: ${{ github.event_name == 'release' }} | |
| run: npm install --global npm@11.6.2 | |
| - name: Verify npm package (dry-run) | |
| if: ${{ github.event_name == 'release' }} | |
| env: | |
| VERSION: ${{ steps.get_version.outputs.VERSION }} | |
| NPM_TAG: ${{ steps.get_version.outputs.NPM_TAG }} | |
| run: | | |
| cd vendor/scripts | |
| BINS=("utoo") | |
| for BIN in "${BINS[@]}"; do | |
| PACKAGE_NAME="$BIN" | |
| if [ "${{ matrix.platform_os }}" = "win32" ]; then | |
| BINARY_PATH="../../target/${{ matrix.target }}/release/${BIN}.exe" | |
| else | |
| BINARY_PATH="../../target/${{ matrix.target }}/release/${BIN}" | |
| fi | |
| ./npm-binary.sh "$PACKAGE_NAME" "$VERSION" "$BINARY_PATH" "${{ matrix.platform_os }}" "${{ matrix.platform_cpu }}" "$NPM_TAG" --dry-run | |
| done | |
| - name: Upload Release Asset | |
| if: ${{ github.event_name == 'release' }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| pwd | |
| ls -la | |
| gh release upload "${GITHUB_REF#refs/tags/}" \ | |
| utoo-${{ matrix.platform_os }}-${{ matrix.platform_cpu }}.tar.gz --clobber | |
| - name: Publish Binary Packages | |
| if: ${{ github.event_name == 'release' }} | |
| env: | |
| VERSION: ${{ steps.get_version.outputs.VERSION }} | |
| NPM_TAG: ${{ steps.get_version.outputs.NPM_TAG }} | |
| run: | | |
| set -e | |
| cd vendor/scripts | |
| BINS=("utoo") | |
| for BIN in "${BINS[@]}"; do | |
| PACKAGE_NAME="$BIN" | |
| if [ "${{ matrix.platform_os }}" = "win32" ]; then | |
| BINARY_PATH="../../target/${{ matrix.target }}/release/${BIN}.exe" | |
| else | |
| BINARY_PATH="../../target/${{ matrix.target }}/release/${BIN}" | |
| fi | |
| ./npm-binary.sh "$PACKAGE_NAME" "$VERSION" "$BINARY_PATH" "${{ matrix.platform_os }}" "${{ matrix.platform_cpu }}" "$NPM_TAG" | |
| done | |
| publish-main: | |
| if: github.event_name == 'release' && startsWith(github.event.release.tag_name, 'utoo-') | |
| needs: build-and-publish-binary | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Get version and tag from release | |
| id: get_version | |
| run: | | |
| if [[ "$GITHUB_REF" == refs/tags/utoo-v* ]]; then | |
| VERSION="${GITHUB_REF#refs/tags/utoo-v}" | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| # Derive the npm tag from the semver prerelease first; fall back to | |
| # the GitHub Release prerelease flag for manually marked releases. | |
| if [[ "$VERSION" == *"-"* ]]; then | |
| PRERELEASE="${VERSION#*-}" | |
| NPM_TAG="${PRERELEASE%%.*}" | |
| echo "NPM_TAG=$NPM_TAG" >> $GITHUB_OUTPUT | |
| echo "Version is prerelease, will publish to '$NPM_TAG' tag" | |
| elif [[ "${{ github.event.release.prerelease }}" == "true" ]]; then | |
| echo "NPM_TAG=beta" >> $GITHUB_OUTPUT | |
| echo "GitHub Release marked as prerelease, will publish to 'beta' tag" | |
| else | |
| echo "NPM_TAG=latest" >> $GITHUB_OUTPUT | |
| echo "GitHub Release is stable, will publish to 'latest' tag" | |
| fi | |
| else | |
| echo "VERSION=0.0.0" >> $GITHUB_OUTPUT | |
| echo "NPM_TAG=dev" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22.14.0 | |
| package-manager-cache: false | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Bump npm CLI for OIDC trusted publisher | |
| # Trusted publishing requires npm 11.5.1+. | |
| run: npm install --global npm@11.6.2 | |
| - name: Publish Main utoo Package | |
| env: | |
| VERSION: ${{ steps.get_version.outputs.VERSION }} | |
| NPM_TAG: ${{ steps.get_version.outputs.NPM_TAG }} | |
| run: | | |
| set -e | |
| cd vendor/scripts | |
| echo "Publishing utoo@$VERSION with npm tag: $NPM_TAG" | |
| ./npm-utoo.sh "$VERSION" "$NPM_TAG" |