Skip to content

Commit

Permalink
integration-pass-3
Browse files Browse the repository at this point in the history
  • Loading branch information
sheurich committed Feb 28, 2024
1 parent 1e67b9f commit e8d1b11
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 19 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
name: Build

# Run on push to main and any pull request.
on:
push:
branches:
- main
pull_request:

permissions:
contents: read
packages: write # Allow docker/build-push-action to publish to GitHub Container Registry
pull-requests: read

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -38,13 +35,20 @@ jobs:
APP: ${{ matrix.app }}
GOARCH: ${{ matrix.go-arch }}
GOOS: ${{ matrix.go-os }}
run: ./build.sh
CGO_ENABLED: 0
LDFLAGS: -s -w
run: |
go build \
-ldflags="${LDFLAGS}" \
-o /tmp/dist/ \
-trimpath \
-v \
./cmd/"${APP}"
- name: Store artifacts
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.go-os }}-${{ matrix.go-arch }}-${{ matrix.app }}
path: dist/

path: /tmp/dist/
docker:
needs:
- build
Expand Down
34 changes: 23 additions & 11 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Checks

# Run on push to main and any pull request.
# Allow manual execution of the workflow.
on:
Expand All @@ -8,29 +7,42 @@ on:
- main
pull_request:
workflow_dispatch:

permissions:
checks: write # Allow write access to checks to allow annotation of code in the PR.
contents: read
pull-requests: read

env:
GO_VERSION: stable
GOLANGCI_LINT_VERSION: v1.56.2
jobs:
checks:
go-lint-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
go-version: ${{ env.GO_VERSION }}
- name: Run GolangCI-Lint
uses: golangci/golangci-lint-action@v4
with:
# skip cache because of flaky behaviors
skip-build-cache: true
skip-pkg-cache: true
version: ${{ env.GOLANGCI_LINT_VERSION }}
go-mod-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Check if go.mod is tidy
run: |
go mod tidy
git diff --exit-code go.mod go.sum || (echo "::error::go.mod and go.sum need to be tidy" && exit 1)
git diff --exit-code go.mod go.sum ||
(echo "::error::go.mod and go.sum need to be tidy" && exit 1)
- name: Check if vendor directory is up to date
run: |
go mod vendor
git diff --exit-code vendor || (echo "::error::vendor directory needs to be updated" && exit 1)
- name: Run GolangCI-Lint
uses: golangci/golangci-lint-action@v4
with:
version: latest
git diff --exit-code vendor ||
(echo "::error::vendor directory needs to be updated" && exit 1)
4 changes: 2 additions & 2 deletions Dockerfile.release
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ FROM linux-base AS linux
ARG APP
ARG TARGETOS
ARG TARGETARCH
COPY --from=dist-files /${TARGETOS}/${TARGETARCH}/${APP} /
COPY --from=dist-files /${APP} /
CMD [ "${APP}" ]

# Use build arguments to select the appropriate binary for Windows
FROM windows-base AS windows
ARG APP
ARG TARGETOS
ARG TARGETARCH
COPY --from=dist-files /${TARGETOS}/${TARGETARCH}/${APP}.exe /
COPY --from=dist-files /${APP}.exe /
CMD [ "${APP}.exe" ]

# Final stage: dynamically select between Linux and Windows stages based on TARGETOS argument
Expand Down

0 comments on commit e8d1b11

Please sign in to comment.