Skip to content

Commit

Permalink
config goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
Divkix committed Sep 5, 2022
1 parent b4616ce commit 0651321
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: release --skip-publish
args: release --skip-publish --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
with:
go-version: 1.19
- name: Create and Push Tag
# only run this step when the tag is not already created
if: startsWith(github.ref, 'refs/tags/') != 'true' && github.event.inputs.tag != ''
run: |-
git config --global user.email "23524935+Divkix@users.noreply.github.com"
git config --global user.name "Divanshu Chauhan"
Expand All @@ -36,6 +38,6 @@ jobs:
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: release
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ ignore.config.json
out/

dist/

dist/
94 changes: 74 additions & 20 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,87 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
project_name: giga
release:
replace_existing_draft: true
header: |
Welcome to this new release!
footer: |
Docker Images:
`docker.io/divideprojects/{{ .ProjectName }}:latest`
`ghcr.io/gigauserbot/{{ .ProjectName }}:latest`
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...
- go mod download
builds:
- env:
- CGO_ENABLED=0
goos:
- goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath
ldflags:
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{ .CommitDate }}
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
- format: binary
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

dockers:
# amd64 only
- goarch: amd64
dockerfile: goreleaser.Dockerfile
use: buildx
image_templates:
- "docker.io/divideprojects/{{ .ProjectName }}:{{ .Tag }}-amd64"
- "ghcr.io/gigauserbot/{{ .ProjectName }}:{{ .Tag }}-amd64"
build_flag_templates:
- "--platform=linux/amd64"
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
extra_files:
- changelog.json
# arm64 only
- goarch: arm64
dockerfile: goreleaser.Dockerfile
use: buildx
image_templates:
- "docker.io/divideprojects/{{ .ProjectName }}:{{ .Tag }}-arm64v8"
- "ghcr.io/gigauserbot/{{ .ProjectName }}:{{ .Tag }}-arm64v8"
build_flag_templates:
- "--platform=linux/arm64/v8"
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
extra_files:
- changelog.json

docker_manifests:
# docker hub
- name_template: "docker.io/divideprojects/{{ .ProjectName }}:{{ .Version }}"
image_templates:
- "docker.io/divideprojects/{{ .ProjectName }}:{{ .Tag }}-amd64"
- "docker.io/divideprojects/{{ .ProjectName }}:{{ .Tag }}-arm64v8"
- name_template: "docker.io/divideprojects/{{ .ProjectName }}:latest"
image_templates:
- "docker.io/divideprojects/{{ .ProjectName }}:{{ .Tag }}-amd64"
- "docker.io/divideprojects/{{ .ProjectName }}:{{ .Tag }}-arm64v8"

# github container registry
- name_template: "ghcr.io/gigauserbot/{{ .ProjectName }}:{{ .Version }}"
image_templates:
- "ghcr.io/gigauserbot/{{ .ProjectName }}:{{ .Tag }}-amd64"
- "ghcr.io/gigauserbot/{{ .ProjectName }}:{{ .Tag }}-arm64v8"
- name_template: "ghcr.io/gigauserbot/{{ .ProjectName }}:latest"
image_templates:
- "ghcr.io/gigauserbot/{{ .ProjectName }}:{{ .Tag }}-amd64"
- "ghcr.io/gigauserbot/{{ .ProjectName }}:{{ .Tag }}-arm64v8"
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Build Stage: Build bot using the alpine image, also install doppler in it
FROM golang:latest AS builder
FROM golang:1.19 AS builder
RUN apt-get update && apt-get upgrade -y && apt-get install build-essential -y
WORKDIR /app
COPY . .
RUN GOOS=`go env GOHOSTOS` GOARCH=`go env GOHOSTARCH` go build -o out/GigaUserbot -ldflags="-w -s" .

# Run Stage: Run bot using the bot and doppler binary copied from build stage
FROM golang:latest
FROM golang:1.19
COPY --from=builder /app/out/GigaUserbot /app/GigaUserbot
COPY changelog.json /app/changelog.json
COPY --from=builder /app/changelog.json /app/changelog.json
CMD ["/app/GigaUserbot"]
3 changes: 3 additions & 0 deletions goreleaser.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM golang:1.19
COPY GIGA changelog.json /app/
CMD ["/app/GigaUserbot"]

0 comments on commit 0651321

Please sign in to comment.