diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 34497d1..af7e012 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,8 +25,9 @@ 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 @@ -34,7 +35,7 @@ jobs: 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 @@ -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 --clean --skip-validate + env: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GO_RELEASER_TOKEN }} + VERSION: ${{ steps.vars.outputs.tag }} diff --git a/max2max/.goreleaser.yaml b/max2max/.goreleaser.yaml new file mode 100644 index 0000000..5fb1ab4 --- /dev/null +++ b/max2max/.goreleaser.yaml @@ -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 }}' diff --git a/max2max/Dockerfile b/max2max/Dockerfile index a467178..c54b4c9 100644 --- a/max2max/Dockerfile +++ b/max2max/Dockerfile @@ -1,4 +1,4 @@ -FROM amd64/alpine:3 +FROM alpine:3 RUN apk --no-cache add tzdata COPY ./build/max2max /usr/local/bin/max2max