Skip to content

Commit f1521cd

Browse files
committed
Simplify Docker nightlies, fix on-demand custom builds
[ci skip] Signed-off-by: Neil Twigg <[email protected]> m
1 parent 67aa107 commit f1521cd

File tree

4 files changed

+20
-40
lines changed

4 files changed

+20
-40
lines changed

.github/actions/nightly-release/action.yaml

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@ name: Nightly Docker Releaser
22
description: Builds nightly docker images
33

44
inputs:
5-
go:
6-
description: The version of go to build with
7-
required: true
8-
9-
label:
10-
description: The label to use for built images
11-
required: true
12-
135
hub_username:
146
description: Docker hub username
157
required: true
@@ -25,35 +17,20 @@ inputs:
2517
runs:
2618
using: composite
2719
steps:
20+
- name: Log in to Docker Hub
21+
shell: bash
22+
run: docker login -u "${{ inputs.hub_username }}" -p "${{ inputs.hub_password }}"
23+
2824
- name: Set up Go
2925
uses: actions/setup-go@v4
3026
with:
31-
go-version: "${{ inputs.go }}"
27+
go-version: "stable"
3228

33-
- name: goreleaser
29+
- name: Build and push Docker images
3430
# Use commit hash here to avoid a re-tagging attack, as this is a third-party action
3531
# Commit 9ed2f89a662bf1735a48bc8557fd212fa902bebf = tag v6.1.0
3632
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf
3733
with:
3834
workdir: "${{ inputs.workdir }}"
39-
version: "~> v2"
40-
args: release --snapshot --config .goreleaser-nightly.yml
41-
42-
- name: images
43-
shell: bash
44-
run: docker images
45-
46-
- name: docker_login
47-
shell: bash
48-
run: docker login -u "${{ inputs.hub_username }}" -p "${{ inputs.hub_password }}"
49-
50-
- name: docker_push
51-
shell: bash
52-
run: |
53-
NDATE=$(date +%Y%m%d)
54-
55-
docker tag synadia/nats-server:nightly-${NDATE} synadia/nats-server:${{ inputs.label }}-${NDATE}
56-
docker tag synadia/nats-server:nightly-${NDATE} synadia/nats-server:${{ inputs.label }}
57-
58-
docker push synadia/nats-server:${{ inputs.label }}-${NDATE}
59-
docker push synadia/nats-server:${{ inputs.label }}
35+
version: ~> v2
36+
args: release --skip=announce,validate --config .goreleaser-nightly.yml

.github/workflows/nightly.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
workflow_dispatch:
44
inputs:
55
target:
6-
description: "Override image branch (optional)"
6+
description: "Override source branch (optional)"
77
type: string
88
required: false
99

@@ -19,11 +19,11 @@ jobs:
1919
with:
2020
path: src/github.com/nats-io/nats-server
2121
ref: ${{ inputs.target || 'main' }}
22+
fetch-depth: 0
23+
fetch-tags: true
2224

2325
- uses: ./src/github.com/nats-io/nats-server/.github/actions/nightly-release
2426
with:
25-
go: "1.23"
2627
workdir: src/github.com/nats-io/nats-server
27-
label: nightly
2828
hub_username: "${{ secrets.DOCKER_USERNAME }}"
2929
hub_password: "${{ secrets.DOCKER_PASSWORD }}"

.goreleaser-nightly.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,19 @@ builds:
1616
- amd64
1717
mod_timestamp: "{{ .CommitTimestamp }}"
1818

19+
release:
20+
disable: true
21+
1922
dockers:
2023
- goos: linux
2124
goarch: amd64
22-
skip_push: true
2325
dockerfile: docker/Dockerfile.nightly
26+
skip_push: false
2427
build_flag_templates:
25-
- '--build-arg=VERSION={{ if index .Env "IMAGE_NAME" }}{{ .Env.IMAGE_NAME }}{{ else if not (eq .Branch "main" "dev" "") }}{{ replace .Branch "/" "-" }}{{ else }}nightly{{ end }}-{{ time "20060102" }}'
28+
- '--build-arg=VERSION={{ if ne .Branch "main" }}{{ replace .Branch "/" "-" }}{{ else }}nightly{{ end }}-{{ time "20060102" }}'
2629
image_templates:
27-
- synadia/nats-server:{{.Version}}
28-
- synadia/nats-server:{{ if index .Env "IMAGE_NAME" }}{{ .Env.IMAGE_NAME }}{{ else if not (eq .Branch "main" "dev" "") }}{{ replace .Branch "/" "-" }}{{ else }}nightly{{ end }}
30+
- synadia/nats-server:{{ if ne .Branch "main" }}{{ replace .Branch "/" "-" }}{{ else }}nightly{{ end }}
31+
- synadia/nats-server:{{ if ne .Branch "main" }}{{ replace .Branch "/" "-" }}{{ else }}nightly{{ end }}-{{ time "20060102" }}
2932
extra_files:
3033
- docker/nats-server.conf
3134

@@ -34,4 +37,4 @@ checksum:
3437
algorithm: sha256
3538

3639
snapshot:
37-
version_template: '{{ if index .Env "IMAGE_NAME" }}{{ .Env.IMAGE_NAME }}{{ else if not (eq .Branch "main" "dev" "") }}{{ replace .Branch "/" "-" }}{{ else }}nightly{{ end }}-{{ time "20060102" }}'
40+
version_template: '{{ if ne .Branch "main" }}{{ replace .Branch "/" "-" }}{{ else }}nightly{{ end }}-{{ time "20060102" }}'

docker/Dockerfile.nightly

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.22-alpine AS builder
1+
FROM golang:alpine AS builder
22

33
ARG VERSION="nightly"
44

0 commit comments

Comments
 (0)