name: release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
build:
name: ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
ext: ""
archive: tar.gz
- target: aarch64-unknown-linux-gnu
os: ubuntu-24.04-arm
ext: ""
archive: tar.gz
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
run: rustup target add ${{ matrix.target }}
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Prepare archive
shell: bash
run: |
BIN="target/${{ matrix.target }}/release/s3ec${{ matrix.ext }}"
ARCHIVE_NAME="s3ec${{ matrix.ext }}"
cp "$BIN" "$ARCHIVE_NAME"
PKG="s3ec-${{ matrix.target }}"
if [ "${{ matrix.archive }}" = "tar.gz" ]; then
tar czf "$PKG.tar.gz" "$ARCHIVE_NAME"
echo "ARTIFACT=$PKG.tar.gz" >> $GITHUB_ENV
else
7z a "$PKG.zip" "$ARCHIVE_NAME"
echo "ARTIFACT=$PKG.zip" >> $GITHUB_ENV
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: s3ec-${{ matrix.target }}
path: ${{ env.ARTIFACT }}
release:
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: s3ec-*
merge-multiple: true
- name: Generate release body
run: |
cat > notes.md <<'EOF'
## s3ec
### Downloads
| Architecture | File |
|---|---|
EOF
for f in *.*; do
[[ "$f" == *.md ]] && continue
[[ "$f" == *.txt ]] && continue
[ -f "$f" ] || continue
arch=$(echo "$f" | sed 's/^s3ec-//; s/\.tar\.gz$//; s/\.zip$//')
echo "| \`$arch\` | \`$f\` |" >> notes.md
done
- name: Create release
uses: softprops/action-gh-release@v2
with:
name: s3ec ${{ github.ref_name }}
body_path: notes.md
files: |
*.tar.gz
*.zip
generate_release_notes: true
publish:
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Restore Cargo.lock
run: git checkout Cargo.lock
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --allow-dirty