-
Notifications
You must be signed in to change notification settings - Fork 3
109 lines (91 loc) · 2.77 KB
/
release.yaml
File metadata and controls
109 lines (91 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Release
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
permissions:
contents: write
on:
push:
# run only against tags
tags:
- "v*"
jobs:
release:
runs-on: ubuntu-latest
if: github.repository_owner == 'ctrlplanedev'
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v7
with:
distribution: goreleaser
version: "~> v2"
args: release --clean --parallelism 2
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
docker:
needs: release
runs-on: ubuntu-latest
if: github.repository_owner == 'ctrlplanedev'
permissions:
contents: read
id-token: write
strategy:
matrix:
platform: [linux/amd64]
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Check if Docker Hub secrets are available
run: |
if [ -z "${{ secrets.DOCKERHUB_USERNAME }}" ] || [ -z "${{ secrets.DOCKERHUB_TOKEN }}" ]; then
echo "DOCKERHUB_LOGIN=false" >> $GITHUB_ENV
else
echo "Credentials are available"
echo "DOCKERHUB_LOGIN=true" >> $GITHUB_ENV
fi
- name: Login to Docker Hub
uses: docker/login-action@v3
if: env.DOCKERHUB_LOGIN == 'true'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ctrlplane/cli
tags: |
type=raw,value=latest
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build Only
uses: docker/build-push-action@v6
if: env.DOCKERHUB_LOGIN != 'true'
with:
push: false
file: docker/Dockerfile
platforms: ${{ matrix.platform }}
tags: ${{ steps.meta.outputs.tags }}
build-args: |
CLI_VERSION=v${{ steps.meta.outputs.version }}
- name: Build and Push
uses: docker/build-push-action@v6
if: env.DOCKERHUB_LOGIN == 'true'
with:
push: true
file: docker/Dockerfile
platforms: ${{ matrix.platform }}
tags: ${{ steps.meta.outputs.tags }}
build-args: |
CLI_VERSION=v${{ steps.meta.outputs.version }}