-
-
Notifications
You must be signed in to change notification settings - Fork 143
143 lines (143 loc) · 5.53 KB
/
build.yaml
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
139
140
141
142
143
on:
push:
tags:
- 'v*.*.*'
name: Build
jobs:
publish:
strategy:
matrix:
os:
- linux
- darwin
- windows
arch:
- amd64
- 386
- arm64
- arm
include:
- os: linux
arch: amd64
artifact_name: dasel_linux_amd64
asset_name: dasel_linux_amd64
build_docker: true
test_version: true
- os: linux
arch: 386
artifact_name: dasel_linux_386
asset_name: dasel_linux_386
build_docker: false
test_version: false
- os: darwin
arch: amd64
artifact_name: dasel_darwin_amd64
asset_name: dasel_darwin_amd64
build_docker: false
test_version: false
- os: darwin
arch: arm64
artifact_name: dasel_darwin_arm64
asset_name: dasel_darwin_arm64
build_docker: false
test_version: false
- os: windows
arch: amd64
artifact_name: dasel_windows_amd64.exe
asset_name: dasel_windows_amd64.exe
build_docker: false
test_version: false
- os: windows
arch: 386
artifact_name: dasel_windows_386.exe
asset_name: dasel_windows_386.exe
build_docker: false
test_version: false
- os: linux
arch: arm64
artifact_name: dasel_linux_arm64
asset_name: dasel_linux_arm64
build_docker: false
test_version: false
- os: linux
arch: arm
artifact_name: dasel_linux_arm32
asset_name: dasel_linux_arm32
build_docker: false
test_version: false
exclude:
- os: darwin
arch: 386
- os: windows
arch: arm64
- os: windows
arch: arm
- os: darwin
arch: arm
name: Build ${{ matrix.os }} ${{ matrix.arch }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '^1.21.0' # The Go version to download (if necessary) and use.
- name: Set env
run: echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV
- name: Build
run: GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} CGO_ENABLED=0 go build -o target/release/${{ matrix.artifact_name }} -ldflags="-X 'github.com/tomwright/dasel/v2/internal.Version=${{ env.RELEASE_VERSION }}'" ./cmd/dasel
- name: Test version
if: matrix.test_version == true
run: ./target/release/${{ matrix.artifact_name }} --version
- name: Gzip binaries
run: gzip -c ./target/release/${{ matrix.artifact_name }} > ./target/release/${{ matrix.artifact_name }}.gz
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/release/${{ matrix.artifact_name }}
asset_name: ${{ matrix.asset_name }}
tag: ${{ github.ref }}
- name: Upload gzip binaries to release
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/release/${{ matrix.artifact_name }}.gz
asset_name: ${{ matrix.asset_name }}.gz
tag: ${{ github.ref }}
- name: Build docker image
if: matrix.build_docker == true
run: |
docker build --build-arg daselpath=target/release/${{ matrix.artifact_name }} -f docker/Dockerfile -t tomwright/dasel:latest .
docker build --build-arg daselpath=target/release/${{ matrix.artifact_name }} -f docker/alpine.Dockerfile -t tomwright/dasel:alpine .
- name: Test docker image
if: matrix.build_docker == true
run: |
echo '{"hello": "World"}' | docker run -i --rm tomwright/dasel:latest -r json 'hello'
echo '{"hello": "World"}' | docker run -i --rm tomwright/dasel:alpine -r json 'hello'
- name: Docker login
if: matrix.build_docker == true
run: echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u TomWright --password-stdin
- name: Docker tag latest
if: matrix.build_docker == true
run: |
docker tag tomwright/dasel:latest ghcr.io/tomwright/dasel:latest
docker tag tomwright/dasel:latest ghcr.io/tomwright/dasel:buster-slim
docker tag tomwright/dasel:alpine ghcr.io/tomwright/dasel:alpine
- name: Docker tag release
if: matrix.build_docker == true
run: |
docker tag tomwright/dasel:latest ghcr.io/tomwright/dasel:${{ env.RELEASE_VERSION }}
docker tag tomwright/dasel:latest ghcr.io/tomwright/dasel:${{ env.RELEASE_VERSION }}-buster-slim
docker tag tomwright/dasel:alpine ghcr.io/tomwright/dasel:${{ env.RELEASE_VERSION }}-alpine
- name: Docker push latest
if: matrix.build_docker == true
run: |
docker push ghcr.io/tomwright/dasel:latest
docker push ghcr.io/tomwright/dasel:buster-slim
docker push ghcr.io/tomwright/dasel:alpine
- name: Docker push release
if: matrix.build_docker == true
run: |
docker push ghcr.io/tomwright/dasel:${{ env.RELEASE_VERSION }}
docker push ghcr.io/tomwright/dasel:${{ env.RELEASE_VERSION }}-buster-slim
docker push ghcr.io/tomwright/dasel:${{ env.RELEASE_VERSION }}-alpine