From b5e48ba9bb466c5e1192755b0235b6b43d1d4966 Mon Sep 17 00:00:00 2001 From: cyqsimon <28627918+cyqsimon@users.noreply.github.com> Date: Tue, 30 Jan 2024 13:29:01 +0800 Subject: CI: include generated assets in release archive (#359) * CI: include generated assets in release archive * Write changelog --- .github/workflows/release.yaml | 50 +++++++++++++++++++++++------------------- CHANGELOG.md | 3 +++ 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d378e16..a9ea033 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -47,6 +47,8 @@ jobs: env: # Emit backtraces on panics. RUST_BACKTRACE: 1 + BANDWHICH_GEN_DIR: assets + PKGDIR: github-actions-pkg strategy: matrix: build: @@ -83,38 +85,40 @@ jobs: run: sudo apt-get install -y --no-install-recommends musl-tools - name: Build release binary + shell: bash env: RUSTFLAGS: "-C strip=symbols" - run: cargo build --verbose --release --target ${{ matrix.target }} + run: | + mkdir -p "$BANDWHICH_GEN_DIR" + cargo build --verbose --release --target ${{ matrix.target }} - - name: Tar release (unix) - if: matrix.os != 'windows-latest' - working-directory: ./target/${{ matrix.target }}/release - run: tar cvfz bandwhich-${{ github.ref_name }}-${{matrix.target}}.tar.gz "bandwhich" + - name: Collect build artifacts + shell: bash + env: + BANDWHICH_BIN: ${{ contains(matrix.os, 'windows') && 'bandwhich.exe' || 'bandwhich' }} + run: | + mkdir "$PKGDIR" + mv "target/${{ matrix.target }}/release/$BANDWHICH_BIN" "$PKGDIR" + mv "$BANDWHICH_GEN_DIR" "$PKGDIR" - - name: Zip Windows release - if: matrix.os == 'windows-latest' - working-directory: ./target/${{ matrix.target }}/release - run: tar.exe -a -c -f bandwhich-${{ github.ref_name }}-${{matrix.target}}.zip "bandwhich.exe" + - name: Tar release (Unix) + if: ${{ !contains(matrix.os, 'windows') }} + working-directory: ${{ env.PKGDIR }} + run: tar cvfz bandwhich-${{ github.ref_name }}-${{ matrix.target }}.tar.gz * - - name: Upload release archive (unix) - if: matrix.os != 'windows-latest' - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ needs.create-release.outputs.upload_url }} - asset_path: ./target/${{ matrix.target }}/release/bandwhich-${{ github.ref_name }}-${{matrix.target}}.tar.gz - asset_name: bandwhich-${{ github.ref_name }}-${{matrix.target}}.tar.gz - asset_content_type: application/octet-stream + - name: Zip release (Windows) + if: contains(matrix.os, 'windows') + shell: bash + working-directory: ${{ env.PKGDIR }} + run: tar.exe -a -c -f bandwhich-${{ github.ref_name }}-${{ matrix.target }}.zip * - - name: Upload Windows release archive - if: matrix.os == 'windows-latest' + - name: Upload release archive uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ARCHIVE_EXT: ${{ contains(matrix.os, 'windows') && 'zip' || 'tar.gz' }} with: upload_url: ${{ needs.create-release.outputs.upload_url }} - asset_path: ./target/${{ matrix.target }}/release/bandwhich-${{ github.ref_name }}-${{matrix.target}}.zip - asset_name: bandwhich-${{ github.ref_name }}-${{matrix.target}}.zip + asset_path: ${{ env.PKGDIR }}/bandwhich-${{ github.ref_name }}-${{ matrix.target }}.${{ env.ARCHIVE_EXT }} + asset_name: bandwhich-${{ github.ref_name }}-${{ matrix.target }}.${{ env.ARCHIVE_EXT }} asset_content_type: application/octet-stream diff --git a/CHANGELOG.md b/CHANGELOG.md index 33b907f..1b96cb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased] +## Added +* CI: include generated assets in release archive #359 - @cyqsimon + ## Changed * CI: strip release binaries for all targets #358 - @cyqsimon -- cgit v1.2.3