add new github release action #55
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Release pod_worker | |
on: | |
push: | |
branches: | |
- rrrliu/go-lib # FIXME: change to main | |
permissions: | |
contents: write | |
jobs: | |
build: | |
name: Build binaries for multiple targets | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
target: | |
- x86_64-unknown-linux-gnu | |
- x86_64-pc-windows-msvc | |
- aarch64-apple-darwin | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v3 | |
- name: Install cross | |
uses: cross-rs/cross@v0.3.0 | |
- name: Build with cross | |
run: | | |
cross build --release --target ${{ matrix.target }} | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.target }} | |
path: | | |
target/${{ matrix.target }}/release/pod_worker* | |
release: | |
name: Create GitHub Release | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Download all artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: ./artifacts | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v3 | |
with: | |
tag_name: "v${{ github.run_number }}-${{ github.run_id }}" # or use your own versioning scheme | |
release_name: "pod_worker ${{ github.run_number }}" | |
body: "Automated release of pod_worker" | |
draft: false | |
prerelease: false | |
- name: Upload Linux x86_64 artifact | |
if: always() | |
uses: actions/upload-release-asset@v3 | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./artifacts/x86_64-unknown-linux-gnu/pod_worker | |
asset_name: pod_worker-linux-x86_64 | |
asset_content_type: application/octet-stream | |
- name: Upload Windows x86_64 artifact | |
if: always() | |
uses: actions/upload-release-asset@v3 | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./artifacts/x86_64-pc-windows-msvc/pod_worker.exe | |
asset_name: pod_worker-windows-x86_64.exe | |
asset_content_type: application/octet-stream | |
- name: Upload Apple aarch64 artifact | |
if: always() | |
uses: actions/upload-release-asset@v3 | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./artifacts/aarch64-apple-darwin/pod_worker | |
asset_name: pod_worker-macos-aarch64 | |
asset_content_type: application/octet-stream |