From 315712c0c78b7cda55ad97c74551ccac68b1f802 Mon Sep 17 00:00:00 2001 From: Marcin Wadon Date: Tue, 3 Sep 2024 22:56:24 +0200 Subject: [PATCH] ci: release action --- .github/workflows/release.yml | 62 +++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f5354d6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,62 @@ +name: Release + +on: + workflow_dispatch: + +jobs: + build-and-release: + name: Build and Release Binaries + runs-on: ubuntu-latest + + strategy: + matrix: + os: [linux, darwin, windows, freebsd] + arch: [amd64, 386, arm64, arm] + exclude: + - os: darwin + arch: 386 + - os: darwin + arch: arm + - os: windows + arch: arm64 + - os: windows + arch: arm + - os: freebsd + arch: 386 + - os: freebsd + arch: arm64 + - os: freebsd + arch: arm + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.20' + + - name: Build Binary + run: | + GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o snapshot-migration-tool_${{ matrix.os }}_${{ matrix.arch }}${{ matrix.os == 'windows' && '.exe' || '' }} + + - name: Create GitHub Release + if: ${{ matrix.os == 'linux' && matrix.arch == 'amd64' }} + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: 'v1.0.0' + release_name: 'v1.0.0' + draft: false + prerelease: false + + - name: Upload Binary + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ steps.create_release.outputs.upload_url || github.event.release.upload_url }} + asset_path: ./snapshot-migration-tool_${{ matrix.os }}_${{ matrix.arch }}${{ matrix.os == 'windows' && '.exe' || '' }} + asset_name: snapshot-migration-tool_${{ matrix.os }}_${{ matrix.arch }}${{ matrix.os == 'windows' && '.exe' || '' }} + asset_content_type: application/octet-stream