Skip to content

Commit

Permalink
chore: use goreleaser instead
Browse files Browse the repository at this point in the history
  • Loading branch information
deryrahman committed Sep 30, 2024
1 parent c3de94e commit 4cca0a8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 28 deletions.
41 changes: 14 additions & 27 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ jobs:
- name: Extract tag version
id: vars
run: |
# Extract the tag name from GITHUB_REF, remove 'refs/tags/bq2bq/' prefix
# Extract the tag name from GITHUB_REF, remove 'refs/tags/bq2bq/v' prefix
TAG="${GITHUB_REF#refs/tags/bq2bq/}"
TAG="${TAG#v}"
echo "Tag name: $TAG"
echo "::set-output name=tag::$TAG"
# Build and push the Docker image to Docker Hub
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./bq2bq
platforms: linux/amd64,linux/arm64 # Specify the target platforms
platforms: linux/amd64 # Specify the target platforms
push: true
tags: |
docker.io/gotocompany/optimus-task-bq2bq-executor:latest
Expand All @@ -53,36 +54,22 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: 1.22
# Build the Go binary
- name: Build
run: |
cd max2max
mkdir build
go get .
env GOOS=linux GOARCH=amd64 go build -o ./build/max2max .
- name: Login to DockerHub
uses: docker/login-action@v1
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Extract the Git tag version
- name: Extract tag version
id: vars
run: |
# Extract the tag name from GITHUB_REF, remove 'refs/tags/max2max/' prefix
# Extract the tag name from GITHUB_REF, remove 'refs/tags/max2max/v' prefix
TAG="${GITHUB_REF#refs/tags/max2max/}"
TAG="${TAG#v}"
echo "Tag name: $TAG"
echo "::set-output name=tag::$TAG"
# Build and push the Docker image to Docker Hub
- name: Build and push Docker image
uses: docker/build-push-action@v5
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
context: ./max2max
platforms: linux/amd64,linux/arm64 # Specify the target platforms
push: true
tags: |
docker.io/gotocompany/max2max:latest
docker.io/gotocompany/max2max:${{ steps.vars.outputs.tag }}
- name: Log out from Docker Hub
run: docker logout
version: latest
args: release --skip=validate --clean
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GO_RELEASER_TOKEN }}
VERSION: ${{ steps.vars.outputs.tag }}
20 changes: 20 additions & 0 deletions max2max/.goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 2

before:
hooks:
- go mod tidy

builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- darwin
goarch:
- amd64
- arm64
dockers:
- dockerfile: Dockerfile
image_templates:
- 'docker.io/gotocompany/max2max:latest'
- 'docker.io/gotocompany/max2max:{{ .Env.VERSION }}'
2 changes: 1 addition & 1 deletion max2max/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM amd64/alpine:3
FROM alpine:3

RUN apk --no-cache add tzdata
COPY ./build/max2max /usr/local/bin/max2max
Expand Down

0 comments on commit 4cca0a8

Please sign in to comment.