diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml deleted file mode 100644 index 4fd83d2..0000000 --- a/.github/workflows/go.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: 'go' - -on: - release: - types: [published] - - pull_request: - types: [opened, synchronize, reopened] - -jobs: - build: - runs-on: ubuntu-latest - steps: - # Checkout the repo - - name: 'Checkout' - uses: actions/checkout@v2 - # Build Go binaries - - name: 'Build Go binaries' - uses: cloudposse/actions/go/build@0.15.0 - env: - GO111MODULE: on - # Architectures to build for - GOX_OSARCH: >- - windows/386 - windows/amd64 - freebsd/arm - netbsd/386 - netbsd/amd64 - netbsd/arm - linux/s390x - linux/arm - darwin/386 - darwin/amd64 - linux/386 - linux/amd64 - freebsd/amd64 - freebsd/386 - openbsd/386 - openbsd/amd64 - OUTPUT_PATH: ${{ github.workspace }}/release/${{ github.event.repository.name }}_ - # Upload artifacts for this build - - name: 'Upload artifacts' - uses: actions/upload-artifact@v2 - with: - name: ${{ github.event.repository.name }} - path: ${{ github.workspace }}/release/* - # Attach Go binaries to GitHub Release - - name: 'Attach artifacts to GitHub Release' - if: ${{ github.event_name == 'release' }} - uses: cloudposse/actions/github/release-assets@0.15.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - INPUT_PATH: ${{ github.workspace }}/release/${{ github.event.repository.name }}_* diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8ca279c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,57 @@ +name: release + +on: + workflow_dispatch: + + release: + types: + - published + + pull_request: + types: + - opened + - synchronize + - reopened + +permissions: + contents: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: '1.20' + + - name: Test Snapshot Release + if: github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && github.ref_name != 'master') + uses: goreleaser/goreleaser-action@v4 + with: + distribution: goreleaser + version: latest + args: release --clean --snapshot + + - name: Upload Test Release Assets + if: github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && github.ref_name != 'master') + uses: actions/upload-artifact@v3 + with: + name: slack-notifier + path: dist/* + retention-days: 3 + + - name: Public Release + if: (github.event_name == 'release' && github.event.action == 'published') || (github.event_name == 'workflow_dispatch' && github.ref_name == 'master') + uses: goreleaser/goreleaser-action@v4 + with: + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 7f02f0c..d1c3a69 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,5 @@ slack-notifier *.out build-harness/ + +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..6ca1c0d --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,35 @@ +before: + hooks: + - go mod download + +builds: + - env: + - CGO_ENABLED=0 + - GO111MODULE=on + goos: + - linux + - windows + - darwin + - freebsd + - openbsd + - netbsd + goarch: + - amd64 + - '386' + - arm + - arm64 + - s390x + +source: + enabled: true + name_template: 'sources' + +archives: + - format: binary + name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}' + +checksum: + name_template: 'checksums.txt' + +snapshot: + name_template: "{{ incpatch .Version }}"