Skip to content

Commit

Permalink
feat: add release workflow and goreleaser config (#5)
Browse files Browse the repository at this point in the history
Create a release workflow that uses goreleaser to release to github.
This workflow is triggered by tag starts with `v`.
  • Loading branch information
sailorlqh authored Jul 27, 2023
1 parent 2f2bfd8 commit 04618cc
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# 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.

name: 'release'
on:
push:
tags:
- 'v*'
permissions:
contents: 'write'
packages: 'write'
jobs:
release:
runs-on: 'ubuntu-latest'
steps:
- uses: 'actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b' # ratchet:actions/checkout@v3
with:
fetch-depth: 0
- uses: 'actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a' # ratchet:actions/setup-go@v3
- uses: 'goreleaser/goreleaser-action@b953231f81b8dfd023c58e0854a721e35037f28b' # ratchet:goreleaser/goreleaser-action@v2
with:
version: 'latest'
args: 'release --clean'
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
59 changes: 59 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# 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.

before:
hooks:
- 'go mod tidy'
- 'go mod verify'

builds:
-
id: 'cli'
main: './src'
env:
- 'CGO_ENABLED=0'
- 'GO111MODULE=on'
- 'GOPROXY=https://proxy.golang.org,direct'
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- '-trimpath'
ldflags:
- '-s'
- '-w'
- '-X=github.com/google-github-actions/send-google-chat-webhook/version.Name={{ .ProjectName }}'
- '-X=github.com/google-github-actions/send-google-chat-webhook/version.Version={{ .Version }}'
- '-X=github.com/google-github-actions/send-google-chat-webhook/version.Commit={{ .Commit }}'
- '-extldflags=-static'
targets:
- 'darwin_amd64'
- 'darwin_arm64'
- 'linux_amd64'
- 'linux_arm64'
- 'windows_amd64'
- 'windows_arm64'
binary: '{{ .ProjectName }}'

archives:
- format: 'tar.gz'
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
format_overrides:
- goos: 'windows'
format: 'zip'

checksum:
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA512SUMS'
algorithm: 'sha512'

release:
draft: false

0 comments on commit 04618cc

Please sign in to comment.