name: Create GitHub Release
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
PROJECT_NAME: usn-parser
jobs:
build_and_package:
name: Build and Package for ${{ matrix.arch }}
runs-on: windows-latest
strategy:
matrix:
include:
- target: x86_64-pc-windows-msvc
arch: x64
asset_name_suffix: x64
- target: aarch64-pc-windows-msvc
arch: arm64
asset_name_suffix: arm64
env:
ZIP_NAME: usn-parser-${{ matrix.asset_name_suffix }}.zip
BINARY_NAME: usn-parser.exe
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Build binary
run: cargo build --verbose --release --target ${{ matrix.target }}
- name: Prepare package directory
shell: pwsh
run: |
$staging_dir = "staging-${{ matrix.asset_name_suffix }}"
New-Item -ItemType Directory -Force -Path $staging_dir
Copy-Item -Path "target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}" -Destination "$staging_dir/${{ env.BINARY_NAME }}"
# You can add other files like README.md, LICENSE to $staging_dir here if you want them in the zip
# Example: Copy-Item -Path "README.md" -Destination "$staging_dir/README.md"
- name: Create Zip Archive
shell: pwsh
run: Compress-Archive -Path "staging-${{ matrix.asset_name_suffix }}/*" -DestinationPath "${{ env.ZIP_NAME }}"
- name: Upload release asset (zip)
uses: actions/upload-artifact@v4
with:
name: ${{ env.ZIP_NAME }} path: ${{ env.ZIP_NAME }} retention-days: 1
publish_github_release:
name: Publish GitHub Release
needs: build_and_package runs-on: ubuntu-latest permissions:
contents: write
steps:
- name: Download all release artifacts
uses: actions/download-artifact@v4
with:
path: release-assets
- name: List downloaded files (for debugging)
run: |
echo "Listing files in release-assets:"
ls -R release-assets
echo "Current tag: ${{ github.ref_name }}"
- name: Create Release and Upload Assets
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/') with:
body: |
Automated release for tag ${{ github.ref_name }}.
Assets:
- Windows x64: `${{ env.PROJECT_NAME }}-x64.zip`
- Windows ARM64: `${{ env.PROJECT_NAME }}-arm64.zip`
files: | release-assets/${{ env.PROJECT_NAME }}-x64.zip/${{ env.PROJECT_NAME }}-x64.zip
release-assets/${{ env.PROJECT_NAME }}-arm64.zip/${{ env.PROJECT_NAME }}-arm64.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}