diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 37bd87f..33b5971 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,12 +15,12 @@ name: 'ci' on: - push: - branches: - - 'main' - pull_request: - branches: - - 'main' + # push: + # branches: + # - 'main' + # pull_request: + # branches: + # - 'main' workflow_dispatch: concurrency: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..15f1a49 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,34 @@ +name: 'release' +on: + push: + tags: + - 'v*' + +# Don't cancel in progress since we don't want to have half-baked release. +concurrency: '${{ github.workflow }}-${{ github.head_ref || github.ref }}-release' + +jobs: + # ci: + # uses: 'abcxyz/access-on-demand/.github/workflows/ci.yml@main' # ratchet:exclude + + github-release: + # Run CI before the release + # needs: ['ci'] + runs-on: 'ubuntu-latest' + environment: release + permissions: + contents: 'write' + packages: 'write' + steps: + - uses: 'actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8' # ratchet:actions/checkout@v3 + with: + fetch-depth: 0 + - uses: 'actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f' # ratchet:actions/setup-go@v3 + with: + go-version: '1.21' + - uses: 'goreleaser/goreleaser-action@b508e2e3ef3b19d4e4146d4f8fb3ba9db644a757' # ratchet:goreleaser/goreleaser-action@v3 + with: + version: 'v1.16.1' # Manually pinned + args: 'release --clean' + env: + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..e73e545 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,68 @@ +# Copyright 2023 The Authors (see AUTHORS file) + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +env: + # Global env vars for Go build. + - 'CGO_ENABLED=0' + - 'GO111MODULE=on' + - 'GOPROXY=https://proxy.golang.org,direct' + +before: + hooks: + - 'go mod tidy' + +builds: + - + id: 'aod' + main: './cmd/aod' + binary: 'aod' + mod_timestamp: '{{ .CommitTimestamp }}' + flags: + - '-a' + - '-trimpath' + ldflags: + - '-s' + - '-w' + - '-X={{ .ModulePath }}/internal/version.Name=aod' + - '-X={{ .ModulePath }}/internal/version.Version={{ .Version }}' + - '-X={{ .ModulePath }}/internal/version.Commit={{ .Commit }}' + - '-extldflags=-static' + goos: + - 'darwin' + - 'linux' + - 'windows' + goarch: + - 'amd64' + - 'arm64' + +archives: + - format: 'tar.gz' + name_template: 'aod_{{ .Version }}_{{ .Os }}_{{ .Arch }}' + format_overrides: + - goos: 'windows' + format: 'zip' + +checksum: + name_template: 'aod_{{ .Version }}_SHA512SUMS' + algorithm: 'sha512' + + +changelog: + use: 'github' + sort: 'asc' + +# Release to github. +release: + draft: false + mode: 'replace'