Skip to content

Commit 2635f2a

Browse files
committed
fix(workflow): remove goreleaser for now, try docker build
Signed-off-by: Toni Tauro <toni.tauro@adfinis.com>
1 parent 22780b2 commit 2635f2a

2 files changed

Lines changed: 125 additions & 48 deletions

File tree

.github/workflows/lint-and-test.yaml

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,38 +26,49 @@ jobs:
2626
with:
2727
go-version: 1.17.x
2828

29-
- name: Run GolangCI-Lint
30-
uses: golangci/golangci-lint-action@v3
31-
with:
32-
args: --timeout 3m
29+
# - name: Run GolangCI-Lint
30+
# uses: golangci/golangci-lint-action@v3
31+
# with:
32+
# args: --timeout 3m
3333

3434
test:
3535
runs-on: ubuntu-latest
3636
steps:
3737
- name: Checkout
3838
uses: actions/checkout@v3
39-
- name: Set up Go
40-
uses: actions/setup-go@v3
41-
with:
42-
go-version: 1.17.x
43-
- name: Build App
44-
run: go build -v ./...
45-
- name: Test App
46-
run: go test -v ./...
4739

48-
goreleaser:
49-
runs-on: ubuntu-latest
50-
steps:
51-
- name: Checkout
52-
uses: actions/checkout@v3
53-
- name: Set up Go
54-
uses: actions/setup-go@v3
55-
with:
56-
go-version: 1.17.x
57-
- name: Run GoReleaser
58-
uses: goreleaser/goreleaser-action@v2.9.1
59-
with:
60-
version: latest
61-
args: --snapshot --skip-publish --rm-dist
62-
env:
63-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
- name: Set up QEMU
41+
uses: docker/setup-qemu-action@v1
42+
43+
- name: Set up Docker Buildx
44+
uses: docker/setup-buildx-action@v1
45+
46+
- name: Test build
47+
id: docker_build
48+
uses: docker/build-push-action@v2
49+
50+
# - name: Set up Go
51+
# uses: actions/setup-go@v3
52+
# with:
53+
# go-version: 1.17.x
54+
# - name: Build App
55+
# run: go build -v ./...
56+
# - name: Test App
57+
# run: go test -v ./...
58+
59+
# goreleaser:
60+
# runs-on: ubuntu-latest
61+
# steps:
62+
# - name: Checkout
63+
# uses: actions/checkout@v3
64+
# - name: Set up Go
65+
# uses: actions/setup-go@v3
66+
# with:
67+
# go-version: 1.17.x
68+
# - name: Run GoReleaser
69+
# uses: goreleaser/goreleaser-action@v2.9.1
70+
# with:
71+
# version: latest
72+
# args: --snapshot --skip-publish --rm-dist
73+
# env:
74+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yaml

Lines changed: 86 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,99 @@
22
name: Release App
33

44
on:
5-
release:
6-
types:
7-
- created
5+
push:
6+
branches: master
7+
tags:
8+
- 'v*.*.*'
89

910
jobs:
10-
goreleaser:
11+
container:
1112
runs-on: ubuntu-latest
1213
steps:
1314
- name: Checkout
14-
uses: actions/checkout@v3
15-
with:
16-
fetch-depth: 0
17-
- name: Set up Go
18-
uses: actions/setup-go@v3
19-
with:
20-
go-version: 1.17.x
21-
- name: Login to GitHub Container Registry
15+
uses: actions/checkout@v2
16+
17+
- name: Set up QEMU
18+
uses: docker/setup-qemu-action@v1
19+
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v1
22+
23+
- name: Prepare Image Metadata
24+
id: prep
25+
run: |
26+
DOCKER_IMAGE=ghcr.io/linkyard/cloudscale-slb-controller
27+
VERSION=noop
28+
if [ "${{ github.event_name }}" = "schedule" ]; then
29+
VERSION=nightly
30+
elif [[ $GITHUB_REF == refs/tags/* ]]; then
31+
VERSION=${GITHUB_REF#refs/tags/}
32+
elif [[ $GITHUB_REF == refs/heads/* ]]; then
33+
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
34+
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then
35+
VERSION=edge
36+
fi
37+
elif [[ $GITHUB_REF == refs/pull/* ]]; then
38+
VERSION=pr-${{ github.event.number }}
39+
fi
40+
TAGS="${DOCKER_IMAGE}:${VERSION}"
41+
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
42+
MINOR=${VERSION%.*}
43+
MAJOR=${MINOR%.*}
44+
TAGS="$TAGS,${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest"
45+
elif [ "${{ github.event_name }}" = "push" ]; then
46+
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
47+
fi
48+
echo ::set-output name=version::${VERSION}
49+
echo ::set-output name=tags::${TAGS}
50+
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
51+
- name: Login to GHCR
2252
uses: docker/login-action@v1
23-
if: github.event_name != 'pull_request'
2453
with:
2554
registry: ghcr.io
26-
username: ${{ github.actor }}
55+
username: ${{ github.repository_owner }}
2756
password: ${{ secrets.GITHUB_TOKEN }}
28-
- name: Run GoReleaser
29-
uses: goreleaser/goreleaser-action@v2.9.1
57+
58+
- name: Build and push
59+
id: docker_build
60+
uses: docker/build-push-action@v2
3061
with:
31-
version: latest
32-
args: release --rm-dist
33-
env:
34-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
context: ./src
63+
file: ./src/Dockerfile
64+
push: ${{ github.event_name != 'pull_request' }}
65+
tags: ${{ steps.prep.outputs.tags }}
66+
labels: |
67+
org.opencontainers.image.title=${{ github.event.repository.name }}
68+
org.opencontainers.image.description=${{ github.event.repository.description }}
69+
org.opencontainers.image.url=${{ github.event.repository.html_url }}
70+
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
71+
org.opencontainers.image.version=${{ steps.prep.outputs.version }}
72+
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
73+
org.opencontainers.image.revision=${{ github.sha }}
74+
org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }}
75+
76+
# goreleaser:
77+
# runs-on: ubuntu-latest
78+
# steps:
79+
# - name: Checkout
80+
# uses: actions/checkout@v3
81+
# with:
82+
# fetch-depth: 0
83+
# - name: Set up Go
84+
# uses: actions/setup-go@v3
85+
# with:
86+
# go-version: 1.17.x
87+
# - name: Login to GitHub Container Registry
88+
# uses: docker/login-action@v1
89+
# if: github.event_name != 'pull_request'
90+
# with:
91+
# registry: ghcr.io
92+
# username: ${{ github.actor }}
93+
# password: ${{ secrets.GITHUB_TOKEN }}
94+
# - name: Run GoReleaser
95+
# uses: goreleaser/goreleaser-action@v2.9.1
96+
# with:
97+
# version: latest
98+
# args: release --rm-dist
99+
# env:
100+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)