-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from chatwork/goreleaser
Use goreleaser and GitHub Actions for image publishing to ghcr.io
- Loading branch information
Showing
5 changed files
with
136 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
|
||
permissions: | ||
# For uploading artifacts | ||
contents: write | ||
# For publishing images to ghcr.io | ||
packages: write | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
if: ${{ !startsWith(github.ref, 'refs/tags/v') }} | ||
run: echo "flags=--snapshot" >> $GITHUB_ENV | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- | ||
name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21.3' | ||
cache: true | ||
- | ||
name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- | ||
name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v4 | ||
with: | ||
distribution: goreleaser | ||
version: latest | ||
args: release --clean ${{ env.flags }} | ||
env: | ||
REGISTRY: ghcr.io/chatwork | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- | ||
name: Upload assets | ||
if: ${{ !startsWith(github.ref, 'refs/tags/v') }} | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: kibertas | ||
path: | | ||
dist/kibertas*.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ kibertas | |
manifests/credentials.yaml | ||
.bin/ | ||
.vscode | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,9 @@ | ||
FROM golang:1.21 AS builder | ||
|
||
ENV CGO_ENABLED=0 | ||
|
||
WORKDIR /app | ||
|
||
COPY go.mod /app | ||
COPY go.sum /app | ||
|
||
RUN go mod download | ||
|
||
COPY . . | ||
|
||
RUN go build -o kibertas . | ||
|
||
FROM gcr.io/distroless/static-debian12 | ||
#FROM amazon/aws-cli:latest | ||
|
||
ARG TARGETOS | ||
ARG TARGETARCH | ||
|
||
COPY --from=builder /app/kibertas /usr/local/bin/kibertas | ||
COPY kibertas /usr/local/bin/kibertas | ||
|
||
ENTRYPOINT ["/usr/local/bin/kibertas"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
project_name: kibertas | ||
env: | ||
builds: | ||
- id: kibertas | ||
main: ./ | ||
env: | ||
- CGO_ENABLED=0 | ||
ldflags: | ||
- -s -w | ||
goos: | ||
- darwin | ||
- linux | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
- "386" | ||
changelog: | ||
use: github-native | ||
|
||
release: | ||
prerelease: auto | ||
|
||
dockers: | ||
# https://goreleaser.com/customization/docker/ | ||
- use: buildx | ||
goos: linux | ||
goarch: amd64 | ||
image_templates: | ||
- "{{ .Env.REGISTRY }}/{{ .ProjectName }}:canary-amd64" | ||
- "{{ .Env.REGISTRY }}/{{ .ProjectName }}:{{ .Version }}-amd64" | ||
- "{{ .Env.REGISTRY }}/{{ .ProjectName }}:{{ .Major }}-amd64" | ||
- "{{ .Env.REGISTRY }}/{{ .ProjectName }}:{{ .Major }}.{{ .Minor }}-amd64" | ||
build_flag_templates: | ||
- "--platform=linux/amd64" | ||
- "--label=org.opencontainers.image.created={{.Date}}" | ||
- "--label=org.opencontainers.image.title={{.ProjectName}}" | ||
- "--label=org.opencontainers.image.revision={{.FullCommit}}" | ||
- "--label=org.opencontainers.image.version={{.Version}}" | ||
- use: buildx | ||
goos: linux | ||
goarch: arm64 | ||
image_templates: | ||
- "{{ .Env.REGISTRY }}/{{ .ProjectName }}:canary-arm64" | ||
- "{{ .Env.REGISTRY }}/{{ .ProjectName }}:{{ .Version }}-arm64" | ||
- "{{ .Env.REGISTRY }}/{{ .ProjectName }}:{{ .Major }}-arm64" | ||
- "{{ .Env.REGISTRY }}/{{ .ProjectName }}:{{ .Major }}.{{ .Minor }}-arm64" | ||
build_flag_templates: | ||
- "--platform=linux/arm64" | ||
- "--label=org.opencontainers.image.created={{.Date}}" | ||
- "--label=org.opencontainers.image.title={{.ProjectName}}" | ||
- "--label=org.opencontainers.image.revision={{.FullCommit}}" | ||
- "--label=org.opencontainers.image.version={{.Version}}" | ||
|
||
docker_manifests: | ||
- name_template: "{{ .Env.REGISTRY }}/{{ .ProjectName }}:canary" | ||
image_templates: | ||
- "{{ .Env.REGISTRY }}/{{ .ProjectName }}:canary-amd64" | ||
- "{{ .Env.REGISTRY }}/{{ .ProjectName }}:canary-arm64" | ||
- name_template: "{{ .Env.REGISTRY }}/{{ .ProjectName }}:{{ .Version }}" | ||
image_templates: | ||
- "{{ .Env.REGISTRY }}/{{ .ProjectName }}:{{ .Version }}-amd64" | ||
- "{{ .Env.REGISTRY }}/{{ .ProjectName }}:{{ .Version }}-arm64" | ||
- name_template: "{{ .Env.REGISTRY }}/{{ .ProjectName }}:{{ .Major }}" | ||
image_templates: | ||
- "{{ .Env.REGISTRY }}/{{ .ProjectName }}:{{ .Major }}-amd64" | ||
- "{{ .Env.REGISTRY }}/{{ .ProjectName }}:{{ .Major }}-arm64" | ||
- name_template: "{{ .Env.REGISTRY }}/{{ .ProjectName }}:{{ .Major }}.{{ .Minor }}" | ||
image_templates: | ||
- "{{ .Env.REGISTRY }}/{{ .ProjectName }}:{{ .Major }}.{{ .Minor }}-amd64" | ||
- "{{ .Env.REGISTRY }}/{{ .ProjectName }}:{{ .Major }}.{{ .Minor }}-arm64" |