From 1043691a880f79d26332decf130fcadd159ff996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Richt=C3=A1rik?= Date: Fri, 26 Sep 2025 09:58:11 +0200 Subject: [PATCH] init --- .github/workflows/build.yaml | 10 ++++----- .github/workflows/publish.yaml | 38 +++++++++++++++++++++++----------- .github/workflows/tag.yaml | 2 +- .goreleaser.yaml | 6 ++++++ Dockerfile | 16 ++++++++------ README.md | 2 ++ 6 files changed, 50 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2890c62..6ec54a0 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -14,13 +14,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Set up Go 1.x - uses: actions/setup-go@v4 + uses: actions/setup-go@v6 with: go-version: ^1.24 id: go - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Get dependencies run: | @@ -42,11 +42,11 @@ jobs: matrix: node-version: [ 20.x ] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 name: Checkout repository - name: setup node ${{matrix.node-version}} - uses: actions/setup-node@v3 + uses: actions/setup-node@v5 with: node-version: ${{matrix.node-version}} @@ -56,4 +56,4 @@ jobs: - name: Build run: yarn build - working-directory: html-report/ui \ No newline at end of file + working-directory: html-report/ui diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 6e3023f..bd9a6bb 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -11,18 +11,18 @@ jobs: steps: - name: Checkout code from repo - uses: actions/checkout@v3 + uses: actions/checkout@v5 with: fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v6 id: go with: go-version: ^1.24 - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v3 + uses: goreleaser/goreleaser-action@v6 with: version: latest args: release --clean @@ -38,17 +38,17 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v5 - name: Set version id: vars - run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} + run: echo "tag=${GITHUB_REF#refs/*/}" >> "$GITHUB_OUTPUT" - name: Check version run: echo "Version ${{ github.event.client_payload.new-tag }}" - name: Use Node.js 20 - uses: actions/setup-node@v3 + uses: actions/setup-node@v5 with: node-version: 20 registry-url: https://registry.npmjs.org/ @@ -57,6 +57,7 @@ jobs: run: | git config --global user.name "pb33f github bot" git config --global user.email "github-bot@pb33f.io" + - name: Create .npmrc file run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc env: @@ -79,16 +80,22 @@ jobs: contents: read steps: - name: Check out the repo - uses: actions/checkout@v3 + uses: actions/checkout@v5 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Log in to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Log in to the Container registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} @@ -96,15 +103,22 @@ jobs: - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@v2 + uses: docker/metadata-action@v5 with: images: | pb33f/openapi-changes ghcr.io/${{ github.repository }} + tags: | + type=raw,value=${{ github.event.client_payload.new-tag }} + type=raw,value=latest - name: Build and push Docker images - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: context: . + platforms: linux/amd64,linux/arm64 push: true - tags: pb33f/openapi-changes:${{ github.event.client_payload.new-tag }}, pb33f/openapi-changes:latest \ No newline at end of file + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/tag.yaml b/.github/workflows/tag.yaml index b870b9e..c10c988 100644 --- a/.github/workflows/tag.yaml +++ b/.github/workflows/tag.yaml @@ -10,7 +10,7 @@ jobs: tag: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v5 - uses: actions-ecosystem/action-get-merged-pull-request@v1 id: get-merged-pull-request diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 04677de..487bcfa 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -10,6 +10,12 @@ builds: - linux - windows - darwin + goarch: + - amd64 + - arm64 + ignore: + - goos: windows + goarch: arm64 archives: - name_template: >- {{ .ProjectName }}_ diff --git a/Dockerfile b/Dockerfile index bf5b6b1..ed6d265 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,9 @@ -FROM golang:1.24-bookworm as builder +FROM --platform=$BUILDPLATFORM golang:1.24-bookworm as builder + +ARG TARGETPLATFORM +ARG BUILDPLATFORM +ARG TARGETOS +ARG TARGETARCH RUN mkdir -p /opt/openapi-changes @@ -7,13 +12,12 @@ WORKDIR /opt/openapi-changes COPY . ./ RUN go mod download && go mod verify -RUN go build -ldflags="-w -s" -v -o /openapi-changes openapi-changes.go +RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags="-w -s" -v -o /openapi-changes openapi-changes.go -FROM debian:bookworm-slim -RUN apt-get update -RUN apt-get --yes install git +FROM --platform=$TARGETPLATFORM debian:bookworm-slim +RUN apt-get update && apt-get --yes install git && rm -rf /var/lib/apt/lists/* WORKDIR /work -COPY --from=0 /openapi-changes / +COPY --from=builder /openapi-changes / ENV PATH=$PATH:/ diff --git a/README.md b/README.md index 8346388..ce274e6 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,8 @@ curl -fsSL https://pb33f.io/openapi-changes/install.sh | sh docker pull pb33f/openapi-changes ``` +Docker images are available for both `linux/amd64` and `linux/arm64` architectures. + To run, mount the current working dir to the container like so: ```