-
Notifications
You must be signed in to change notification settings - Fork 2
117 lines (98 loc) · 3.03 KB
/
publish.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
name: Build and Publish
on:
push:
tags:
- 'v*.*.*'
jobs:
tests:
uses: ./.github/workflows/tests.yaml
release:
name: Release wpex ${{ github.ref_name }}
runs-on: ubuntu-latest
needs: [ tests ]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Create Release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref_name }}
draft: false
prerelease: false
outputs:
upload_url: ${{ steps.create-release.outputs.upload_url }}
docker:
name: Build and Publish Docker Image
runs-on: ubuntu-latest
needs: [ release ]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/wpex
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get Version
id: version
run: echo version=${GITHUB_REF##*v} >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v4
with:
build-args: WPEX_VERSION=${{ steps.version.outputs.version }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
binary:
name: Build and Publish Pre-built binaries
runs-on: ubuntu-latest
needs: [ release ]
strategy:
matrix:
GOOS: [ darwin, linux, windows ]
GOARCH: [ 386, amd64, arm64 ]
exclude:
- GOOS: darwin
GOARCH: 386
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Golang
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Get Version
id: version
run: echo version=${GITHUB_REF##*v} >> $GITHUB_OUTPUT
- name: Build wpex
run: >-
CGO_ENABLED=0
GOOS=${{ matrix.GOOS }}
GOARCH=${{ matrix.GOARCH }}
go build -ldflags="-w -s -X main.version=${{ steps.version.outputs.version }}" -o wpex
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ./wpex
asset_name: wpex_${{ steps.version.outputs.version }}_${{ matrix.GOOS }}_${{ matrix.GOARCH }}
asset_content_type: application/zip