-
-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (118 loc) · 4.23 KB
/
release.yml
File metadata and controls
138 lines (118 loc) · 4.23 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: Release Wiredoor CLI
on:
push:
branches:
- main
tags:
- "v*.*.*"
jobs:
build-and-package:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
packages: write
env:
CLI_NAME: wiredoor
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.25
- name: Get version from tag
id: version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
- name: Install FPM dependencies
run: |
sudo apt-get update
sudo apt-get install -y ruby ruby-dev build-essential rpm make libarchive-tools zstd curl librsvg2-bin gettext-base
sudo gem install --no-document fpm
- name: Package .deb and .rpm
run: |
mkdir -p dist
make build-pkgs VERSION=${VERSION} OUT_PATH=dist
- name: Upload packages to GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
dist/*.deb
dist/*.rpm
dist/*.apk
dist/*.pkg.tar.zst
dist/*.exe
dist/*.tar.gz
build-image:
name: Build Gateway Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref != '' && inputs.ref || github.sha }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.WIREDOOR_GHCR_TOKEN != '' && secrets.WIREDOOR_GHCR_TOKEN || secrets.GITHUB_TOKEN }}
- name: Prepare Image names and decide DockerHub publish
id: img
env:
DOCKER_HUB_USERNAME: ${{ secrets.WIREDOOR_DOCKER_HUB_USERNAME }}
DOCKER_HUB_TOKEN: ${{ secrets.WIREDOOR_DOCKER_HUB_TOKEN }}
run: |
GHCR="ghcr.io/${{ github.repository }}"
GHCR_LC=$(echo "$GHCR" | tr '[:upper:]' '[:lower:]')
echo "GHCR_IMAGE=$GHCR_LC" >> $GITHUB_OUTPUT
if [[ -n "$DOCKER_HUB_USERNAME" && -n "$DOCKER_HUB_TOKEN" && ( "$GITHUB_REF" == "refs/heads/main" || "$GITHUB_REF" == refs/tags/* ) ]]; then
echo "PUBLISH_DH=true" >> $GITHUB_OUTPUT
else
echo "PUBLISH_DH=false" >> $GITHUB_OUTPUT
fi
{
echo "IMAGE_LIST<<EOF"
echo "$GHCR_LC"
if [[ -n "$DOCKER_HUB_USERNAME" && -n "$DOCKER_HUB_TOKEN" && ( "$GITHUB_REF" == "refs/heads/main" || "$GITHUB_REF" == refs/tags/* ) ]]; then
echo "wiredoor/wiredoor-cli"
fi
echo "EOF"
} >> $GITHUB_OUTPUT
- name: Login to Docker Hub
if: ${{ steps.img.outputs.PUBLISH_DH == 'true' }}
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.WIREDOOR_DOCKER_HUB_USERNAME }}
password: ${{ secrets.WIREDOOR_DOCKER_HUB_TOKEN }}
- name: Extract Docker metadata (tags + labels)
id: meta
with:
images: ${{ steps.img.outputs.IMAGE_LIST }}
tags: |
type=ref,event=tag
type=raw,value=stable,enable=${{ startsWith(github.ref, 'refs/tags/') }}
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=raw,value=dev,enable=${{ github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/') }}
type=sha,prefix=dev-,format=short,enable=${{ github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/') }}
uses: docker/metadata-action@v5
- name: Build and Push
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
target: production
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
provenance: mode=max
sbom: true