From 24f7f106e012e1f14a2ddf4bebe7b2a76c6fb3cb Mon Sep 17 00:00:00 2001 From: rjshrjndrn Date: Sun, 11 Feb 2024 10:11:04 +0100 Subject: [PATCH] release using go releaser Signed-off-by: rjshrjndrn --- .github/workflows/release.yaml | 111 ++++++++++----------------------- 1 file changed, 32 insertions(+), 79 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 734762b..b917484 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,87 +1,40 @@ -name: Build and Release +# .github/workflows/release.yml +name: goreleaser on: + pull_request: push: + # run only against tags tags: - - 'v*' + - "*" -jobs: - build: - name: Build on Commit - runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' - steps: - - name: Check out code - uses: actions/checkout@v2 +permissions: + contents: write + # packages: write + # issues: write - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: '1.19.x' - - - name: Build - run: | - go build -o templater - ./templater - - release: - name: Build and Release Binaries - needs: build +jobs: + goreleaser: runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - arch: [amd64, '386'] - include: - - os: ubuntu-latest - platform: linux - - os: windows-latest - platform: windows - - os: macos-latest - platform: darwin - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: '1.19.x' # Specify your Go version here - - - name: Build binaries - env: - GOOS: ${{ matrix.platform }} - GOARCH: ${{ matrix.arch }} - run: | - go build -o templater-${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.os == 'windows-latest' && '.exe' || '' }} - - - name: Upload artifact - uses: actions/upload-artifact@v2 - with: - name: templater-${{ matrix.platform }}-${{ matrix.arch }} - path: templater-${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.os == 'windows-latest' && '.exe' || '' }} - - - name: Create Release - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref_name }} - release_name: Release ${{ github.ref_name }} - draft: false - prerelease: false - - - name: Upload Release Asset - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./templater-${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.os == 'windows-latest' && '.exe' || '' }} - asset_name: templater-${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.os == 'windows-latest' && '.exe' || '' }} - asset_content_type: application/octet-stream + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: stable + # More assembly might be required: Docker logins, GPG, etc. + # It all depends on your needs. + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 + with: + # either 'goreleaser' (default) or 'goreleaser-pro' + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution + # GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}