Skip to content

Commit

Permalink
refactor: local build thru make targets (#88)
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian authored Feb 5, 2025
1 parent ed2338c commit 9dbbe12
Show file tree
Hide file tree
Showing 20 changed files with 3,060 additions and 215 deletions.
4 changes: 4 additions & 0 deletions .chglog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
conventional-commits: true
debug: false
owner: "goreleaser"
package-name: "goreleaser-cross"
5 changes: 2 additions & 3 deletions .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GO_VERSION=1.23.3
GO_VERSION=1.23.5
TOOLCHAINS_VERSION=v0.1.8
GIT_CHGLOG_VERSION=v0.15.0
GORELEASER_VERSION=2.6.0
Expand All @@ -8,5 +8,4 @@ OSX_VERSION_MIN=10.9
OSX_CROSS_COMMIT=e59a63461da2cbc20cb0a5bbfc954730e50a5472
DEBIAN_FRONTEND=noninteractive
TINI_VERSION=v0.19.0
COSIGN_VERSION=2.4.0
COSIGN_SHA256=fd5b09be23ef1027e1bdd490ce78dcc65d2b15902e1f4ba8e04f3b4019cc1057
COSIGN_VERSION=2.4.1
13 changes: 13 additions & 0 deletions .github/workflows/dispatch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
name: dispatch
jobs:
runs-on: ubuntu-latest
steps:
- name: notify goreleaser-cross with new release
if: success() && startsWith(github.ref, 'refs/tags/v')
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.GH_PAT }}
repository: goreleaser/goreleaser-cross
event-type: goreleaser
client-payload: '{"tag": "${{ env.RELEASE_TAG }}"}'
57 changes: 29 additions & 28 deletions .github/workflows/goreleaser-bump.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: goreleaser-bump

on:
Expand All @@ -9,34 +10,34 @@ jobs:
goreleaser-bump:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: true
- run: git checkout master
- name: Setup git config
run: |
git config --global user.name github-actions
git config --global user.email "[email protected]"
- name: Setup env
uses: c-py/action-dotenv-to-setenv@v3
with:
env-file: .env
- name: Goreleaser version
run: |
GORELEASER_VER=${{ github.event.inputs.tag }}
echo "GORELEASER_VER=${GORELEASER_VER#v}" >> $GITHUB_ENV
- name: set new version
run: |
sed -i -e "s/GORELEASER_VERSION=${{ env.GORELEASER_VERSION }}/GORELEASER_VERSION=${{ env.GORELEASER_VER }}/g" .env
- name: Commit new version
run: |
if git add .env > /dev/null 2>&1; then
git commit -m "feat: bump goreleaser to v${{ env.GORELEASER_VER }}"
git push origin master
fi
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: true
- run: git checkout master
- name: Setup git config
run: |
git config --global user.name github-actions
git config --global user.email "[email protected]"
- name: Setup env
uses: c-py/action-dotenv-to-setenv@v3
with:
env-file: .env
- name: Goreleaser version
run: |
GORELEASER_VER=${{ github.event.inputs.tag }}
echo "GORELEASER_VER=${GORELEASER_VER#v}" >> $GITHUB_ENV
- name: set new version
run: |
sed -i -e "s/GORELEASER_VERSION=${{ env.GORELEASER_VERSION }}/GORELEASER_VERSION=${{ env.GORELEASER_VER }}/g" .env
- name: Commit new version
run: |
if git add .env > /dev/null 2>&1; then
git commit -m "feat: bump goreleaser to v${{ env.GORELEASER_VER }}"
git push origin master
fi
notify-goreleaser-bump:
runs-on: ubuntu-latest
needs:
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/release-base.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: release
on:
push:
Expand All @@ -11,18 +12,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- run: git fetch --prune --unshallow
- name: Setup env
uses: c-py/action-dotenv-to-setenv@v3
Expand All @@ -38,13 +39,13 @@ jobs:
echo "$cross_base_tags" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
- name: Install cosign
uses: sigstore/cosign-installer@main
- name: Build and push base images
uses: docker/build-push-action@v3
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/release-goreleaser-pro.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: goreleaser-pro

on:
Expand All @@ -12,13 +13,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
Expand All @@ -44,9 +45,9 @@ jobs:
uses: tj-actions/branch-names@v6
id: branch-name
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
- name: Install cosign
uses: sigstore/cosign-installer@main
- uses: actions/setup-go@v3
Expand All @@ -58,7 +59,7 @@ jobs:
# sudo docker image prune --all --force
# sudo docker builder prune -a
- name: Build and push goreleaser pro image
uses: docker/build-push-action@v3
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/release-goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: goreleaser
on:
workflow_dispatch:
Expand All @@ -11,13 +12,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
Expand All @@ -43,9 +44,9 @@ jobs:
uses: tj-actions/branch-names@v6
id: branch-name
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
- name: Install cosign
uses: sigstore/cosign-installer@main
- uses: actions/setup-go@v3
Expand All @@ -57,7 +58,7 @@ jobs:
# sudo docker image prune --all --force
# sudo docker builder prune -a
- name: Build and push goreleaser image
uses: docker/build-push-action@v3
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# golang parameters
ARG TAG_VERSION
ARG GORELEASER_VERSION
ARG GORELEASER_DISTRIBUTION
ARG GORELEASER_DISTRIBUTION=""
ARG BASE_VERSION=latest

FROM ghcr.io/goreleaser/goreleaser$GORELEASER_DISTRIBUTION:v$GORELEASER_VERSION$GORELEASER_DISTRIBUTION as goreleaser
FROM ghcr.io/goreleaser/goreleaser$GORELEASER_DISTRIBUTION:v$GORELEASER_VERSION$GORELEASER_DISTRIBUTION AS goreleaser

FROM ghcr.io/goreleaser/goreleaser-cross-base:$TAG_VERSION
FROM ghcr.io/goreleaser/goreleaser-cross-base:$BASE_VERSION

LABEL maintainer="Artur Troian <troian dot ap at gmail dot com>"
LABEL "org.opencontainers.image.source"="https://github.com/goreleaser/goreleaser-cross"
Expand Down
13 changes: 6 additions & 7 deletions Dockerfile.base
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
ARG COSIGN_VERSION
ARG COSIGN_SHA256
ARG TOOLCHAINS_VERSION

FROM ghcr.io/sigstore/cosign/cosign:v$COSIGN_VERSION@sha256:$COSIGN_SHA256 as cosign
ARG TOOLCHAINS_TAG=v0.1.8

FROM ghcr.io/goreleaser/goreleaser-cross-toolchains:$TOOLCHAINS_VERSION
FROM ghcr.io/goreleaser/goreleaser-cross-toolchains:${TOOLCHAINS_TAG}

LABEL maintainer="Artur Troian <troian dot ap at gmail dot com>"
LABEL "org.opencontainers.image.source"="https://github.com/goreleaser/goreleaser-cross-base"
Expand All @@ -13,6 +9,7 @@ ARG DEBIAN_FRONTEND=noninteractive
ARG TINI_VERSION
ARG GO_VERSION
ARG TARGETARCH
ARG COSIGN_VERSION

COPY entrypoint.sh /

Expand Down Expand Up @@ -40,9 +37,11 @@ RUN \
&& wget https://go.dev/dl/go${GO_VERSION}.linux-${TARGETARCH}.tar.gz \
&& rm -rf /usr/local/go && tar -C /usr/local -xzf go${GO_VERSION}.linux-${TARGETARCH}.tar.gz \
&& rm go${GO_VERSION}.linux-${TARGETARCH}.tar.gz \
&& wget https://github.com/sigstore/cosign/releases/download/v2.4.1/cosign_${COSIGN_VERSION}_${TARGETARCH}.deb \
&& dpkg -i cosign_${COSIGN_VERSION}_${TARGETARCH}.deb \
&& rm cosign_${COSIGN_VERSION}_${TARGETARCH}.deb \
&& chmod +x /entrypoint.sh

COPY --from=cosign /ko-app/cosign /usr/local/bin/cosign
COPY --from=docker/buildx-bin:latest /buildx /usr/libexec/docker/cli-plugins/docker-buildx

ENV OSX_CROSS_PATH=/usr/local/osxcross
Expand Down
Loading

0 comments on commit 9dbbe12

Please sign in to comment.