From d0f8207a25bc4981acb844476d801772aea13337 Mon Sep 17 00:00:00 2001 From: michaelessiet Date: Sun, 17 Nov 2024 18:34:45 +0100 Subject: [PATCH] feat: release workflow --- .github/workflows/release.yaml | 73 ++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..c834b48 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,73 @@ +# .github/workflows/release.yml +name: Release + +on: + push: + tags: + - 'v*' + +jobs: + create-release: + runs-on: ubuntu-latest + outputs: + upload_url: ${{ steps.create_release.outputs.upload_url }} + steps: + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + + build-and-publish: + needs: create-release + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + include: + - os: macos-latest + artifact_name: goon + asset_name: goon-darwin-amd64 + - os: ubuntu-latest + artifact_name: goon + asset_name: goon-linux-amd64 + # - os: windows-latest + # artifact_name: goon.exe + # asset_name: goon-windows-amd64.exe + + steps: + - uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + target: ${{ matrix.os == 'macos-latest' && 'x86_64-apple-darwin' || matrix.os == 'ubuntu-latest' && 'x86_64-unknown-linux-gnu' }} + # target: ${{ matrix.os == 'ubuntu-latest' && 'x86_64-unknown-linux-gnu' || matrix.os == 'macos-latest' && 'x86_64-apple-darwin' || 'x86_64-pc-windows-msvc' }} + + - name: Build + uses: actions-rs/cargo@v1 + with: + command: build + args: --release --locked + + # - name: Strip binary (Unix) + # if: matrix.os != 'windows-latest' + # run: strip target/release/${{ matrix.artifact_name }} + + - name: Upload Release Asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create-release.outputs.upload_url }} + asset_path: target/release/${{ matrix.artifact_name }} + asset_name: ${{ matrix.asset_name }} + asset_content_type: application/octet-stream