Skip to content
This repository was archived by the owner on Jul 23, 2024. It is now read-only.

Commit 0544dfa

Browse files
committed
Switch to GitHub Actions
1 parent 5e7f5bd commit 0544dfa

File tree

7 files changed

+204
-144
lines changed

7 files changed

+204
-144
lines changed

.dockerignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*
2+
!/docker/
3+
!/internal/
4+
!/vendor/
5+
!/.dockerignore
6+
!/go.mod
7+
!/go.sum
8+
!/main.go

.github/dependabot.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "gomod"
4+
directory: "/"
5+
schedule:
6+
interval: "monthly"
7+
open-pull-requests-limit: 10
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "monthly"
12+
open-pull-requests-limit: 10

.github/workflows/main.yml

+167
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
name: main
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v*'
9+
pull_request:
10+
branches:
11+
- '*'
12+
13+
jobs:
14+
build:
15+
name: Build
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
20+
21+
- name: Setup Go
22+
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
23+
with:
24+
go-version-file: 'go.mod'
25+
26+
- name: Download dependencies
27+
run: |
28+
go mod download
29+
30+
- name: Run unit tests
31+
run: |
32+
go test -v -race -coverprofile=coverage.txt -covermode=atomic $(go list ./...)
33+
34+
# TODO: enable after fixing linter issues
35+
# - name: Run linter
36+
# uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0
37+
# with:
38+
# version: v1.52.2
39+
# args: --verbose
40+
# # See: https://github.com/golangci/golangci-lint-action/issues/244
41+
# skip-pkg-cache: true
42+
# skip-build-cache: true
43+
44+
- name: Build
45+
run: |
46+
go build -v -o ./bin/envexec .
47+
48+
docker:
49+
name: Docker
50+
runs-on: ubuntu-latest
51+
needs:
52+
- build
53+
env:
54+
IMAGE_NAME: hypnoglow/envexec
55+
# For PR, we only build for AMD64, just to be sure that Docker build works.
56+
# For main branch and tags we also build for ARM64.
57+
# Note that building for ARM64 is very slow.
58+
IMAGE_PLATFORMS: |
59+
linux/amd64
60+
${{ github.event_name != 'pull_request' && 'linux/arm64' || '' }}
61+
steps:
62+
- name: Checkout
63+
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
64+
65+
- name: Setup Go
66+
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
67+
with:
68+
go-version-file: 'go.mod'
69+
70+
- name: Download dependencies
71+
run: |
72+
go mod download
73+
go mod vendor
74+
75+
- name: Login to Docker Hub
76+
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.0
77+
with:
78+
username: ${{ secrets.DOCKERHUB_USERNAME }}
79+
password: ${{ secrets.DOCKERHUB_TOKEN }}
80+
if: github.event_name != 'pull_request'
81+
82+
# Used for arm images.
83+
- name: Set up QEMU
84+
uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 # v2.2.0
85+
with:
86+
platforms: ${{ env.IMAGE_PLATFORMS }}
87+
88+
- name: Set up Docker Buildx
89+
uses: docker/setup-buildx-action@885d1462b80bc1c1c7f0b00334ad271f09369c55 # v2.10.0
90+
91+
- name: Extract Docker image metadata (alpine)
92+
id: docker_meta_alpine
93+
uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175 # v4.6.0
94+
with:
95+
images: |
96+
${{ env.IMAGE_NAME }}
97+
flavor: |
98+
suffix=-alpine
99+
tags: |
100+
type=ref,event=pr
101+
type=ref,event=branch,enable={{ is_default_branch }}
102+
type=semver,pattern={{ version }}
103+
104+
- name: Extract Docker image metadata (scratch)
105+
id: docker_meta_scratch
106+
uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175 # v4.6.0
107+
with:
108+
images: |
109+
${{ env.IMAGE_NAME }}
110+
flavor: |
111+
suffix=-scratch
112+
tags: |
113+
type=ref,event=pr
114+
type=ref,event=branch,enable={{ is_default_branch }}
115+
type=semver,pattern={{ version }}
116+
117+
- name: Build and push Docker image (alpine)
118+
uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825 # v4.1.1
119+
with:
120+
file: docker/alpine/Dockerfile
121+
context: .
122+
platforms: ${{ env.IMAGE_PLATFORMS }}
123+
tags: ${{ steps.docker_meta_alpine.outputs.tags }}
124+
labels: ${{ steps.docker_meta_alpine.outputs.labels }}
125+
push: ${{ github.event_name != 'pull_request' }}
126+
127+
- name: Build and push Docker image (scratch)
128+
uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825 # v4.1.1
129+
with:
130+
file: docker/scratch/Dockerfile
131+
context: .
132+
platforms: ${{ env.IMAGE_PLATFORMS }}
133+
tags: ${{ steps.docker_meta_scratch.outputs.tags }}
134+
labels: ${{ steps.docker_meta_scratch.outputs.labels }}
135+
push: ${{ github.event_name != 'pull_request' }}
136+
137+
goreleaser:
138+
name: GoReleaser
139+
runs-on: ubuntu-latest
140+
needs:
141+
- build
142+
permissions:
143+
contents: write
144+
if: startsWith(github.ref, 'refs/tags/')
145+
steps:
146+
- name: Checkout
147+
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
148+
with:
149+
fetch-depth: 0
150+
151+
- name: Setup Go
152+
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
153+
with:
154+
go-version-file: 'go.mod'
155+
156+
- name: Download dependencies
157+
run: |
158+
go mod download
159+
160+
- name: Run GoReleaser
161+
uses: goreleaser/goreleaser-action@3fa32b8bb5620a2c1afe798654bbad59f9da4906 # v4.4.0
162+
with:
163+
version: latest
164+
args: release --clean
165+
env:
166+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
167+
GORELEASER_PREVIOUS_TAG: ""

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/bin/
12
/vendor/
23

34
/envexec

.goreleaser.yml

+15-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
builds:
2-
- env:
3-
- CGO_ENABLED=0
4-
- GOFLAGS=-mod=vendor
2+
- flags:
3+
- -trimpath
4+
env:
5+
- CGO_ENABLED=0
56

6-
archive:
7-
format: tar.gz
8-
replacements:
9-
darwin: Darwin
10-
linux: Linux
11-
windows: Windows
12-
386: i386
13-
amd64: x86_64
14-
wrap_in_directory: true
7+
archives:
8+
- id: tar
9+
format: tar.gz
10+
11+
release:
12+
draft: true
13+
14+
# The lines beneath this are called `modelines`. See `:help modeline`
15+
# Feel free to remove those if you don't want/use them.
16+
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
17+
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

.tool-versions

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
golang 1.20.8
2+
golangci-lint 1.52.2

codefresh.yml

-132
This file was deleted.

0 commit comments

Comments
 (0)