Skip to content

fix(cd): install cargo tag in place of cargo edit #79

fix(cd): install cargo tag in place of cargo edit

fix(cd): install cargo tag in place of cargo edit #79

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
version:
type: choice
required: true
description: 'Version number to bump'
options:
- patch
- minor
- major
push:
branches:
- main
permissions:
contents: write
issues: write
pull-requests: write
jobs:
publish-dry-run:
name: "Runs cargo publish --dry-run"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- name: Setup Cargo Binstall
uses: cargo-bins/cargo-binstall@main
- name: Install Rust Binaries
run: |
cargo binstall -y --force cargo-edit
cargo binstall -y --force leptosfmt
cargo binstall -y --force trunk
- name: Build (debug)
run: make build
- name: publish crate
run: |
cargo package --list --allow-dirty
cargo publish -p http-server --dry-run --allow-dirty
build-binaries:
name: Build binaries
if: always() && (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && needs.publish-dry-run.result == 'success'))
strategy:
matrix:
include:
- name: linux-x64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- name: linux-arm64
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
- name: macos-x64
os: macos-latest
target: x86_64-apple-darwin
- name: macos-arm64
os: macos-latest
target: aarch64-apple-darwin
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: |
wasm32-unknown-unknown
${{ matrix.target }}
- name: Install Linker for ARM64 Linux GNU
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Setup Cargo Binstall
uses: cargo-bins/cargo-binstall@main
- name: Install Rust Binaries
run: |
cargo binstall -y --force cargo-tag
cargo binstall -y --force leptosfmt
cargo binstall -y --force trunk
- name: Retrieve Version
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
cd ./src/http-server
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "CRATE_VERSION=$(cargo tag --no-commit --no-tag -p=v ${{ inputs.version }})" >> $GITHUB_ENV
else
echo "CRATE_VERSION=$(cargo tag --no-commit --no-tag -p=v prerelease pre.$(date +%Y%m%d%H%M%S))" >> $GITHUB_ENV
fi
- name: Build binary
run: make release TARGET=${{ matrix.target }}
- name: Package binary
run: |
# Create binary name with version and target
BINARY_NAME="http-server-${{ env.CRATE_VERSION }}-${{ matrix.name }}"
# Copy and rename binary
if [ "${{ matrix.os }}" == "ubuntu-latest" ] || [ "${{ matrix.os }}" == "macos-latest" ]; then
cp target/${{ matrix.target }}/release/http-server $BINARY_NAME
fi
# Create tar.gz archive
tar -czf $BINARY_NAME.tar.gz $BINARY_NAME
# Store artifact name for later use
echo "ARTIFACT_NAME=$BINARY_NAME.tar.gz" >> $GITHUB_ENV
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_NAME }}
release:
name: Create Release
needs: build-binaries
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: |
wasm32-unknown-unknown
${{ matrix.target }}
- name: Setup Cargo Binstall
uses: cargo-bins/cargo-binstall@main
- name: Install Rust Binaries
run: |
cargo binstall -y --force cargo-tag
- name: Commit Version Bump
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
cd ./src/http-server
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "CRATE_VERSION=$(cargo tag --no-commit --no-tag -p=v ${{ inputs.version }})" >> $GITHUB_ENV
else
echo "CRATE_VERSION=$(cargo tag --no-commit --no-tag -p=v prerelease pre.$(date +%Y%m%d%H%M%S))" >> $GITHUB_ENV
fi
git push origin main --follow-tags
- name: Login to Crates.io
if: github.event_name == 'workflow_dispatch'
run: cargo login ${CRATES_IO_TOKEN}
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
- name: Publish crate
if: github.event_name == 'workflow_dispatch'
run: |
cargo package --list --allow-dirty
cargo publish -p http-server --allow-dirty
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Create Release with GitHub CLI
env:
GH_TOKEN: ${{ github.token }}
run: |
# Determine if this is a pre-release
IS_PRERELEASE=""
if [ "${{ github.event_name }}" == "push" ]; then
IS_PRERELEASE="--prerelease"
fi
# Create the release
gh release create "${{ env.CRATE_VERSION }}" \
--title "Release ${{ env.CRATE_VERSION }}" \
--generate-notes \
$IS_PRERELEASE
# Upload all binary artifacts
for artifact_dir in ./artifacts/*/; do
if [ -d "$artifact_dir" ]; then
for file in "$artifact_dir"*.tar.gz; do
if [ -f "$file" ]; then
echo "Uploading $(basename "$file")"
gh release upload "${{ env.CRATE_VERSION }}" "$file"
fi
done
fi
done