-
Notifications
You must be signed in to change notification settings - Fork 5
101 lines (97 loc) · 3.55 KB
/
release-new-version.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
# workflow name
name: Generate release-artifacts
# on events
on:
push:
tags:
- '*'
# workflow tasks
#https://trstringer.com/github-actions-create-release-upload-artifacts/
jobs:
generate:
name: Generate cross-platform builds
runs-on: ubuntu-20.04
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: '1.20'
check-latest: true
- name: version
run: echo "::set-output name=version::$(git describe --tags --always --abbrev=0 --match='[0-9]*.[0-9]*.[0-9]*' 2> /dev/null)"
id: version
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run Linux Build
run: go build -ldflags="-X 'k8f/cmd.tversion=${{ steps.version.outputs.version }}'" .
- name: Run Windows Build
run: env GOOS=windows GOARCH=amd64 go build -ldflags="-X 'k8f/cmd.tversion=${{ steps.version.outputs.version }}'" -o ./k8f.exe .
- name: Run Mac Amd arch Build
run: env GOOS=darwin GOARCH=amd64 go build -ldflags="-X 'k8f/cmd.tversion=${{ steps.version.outputs.version }}'" -o ./k8f_darwin_amd .
- name: Run Mac Arm arch Build
run: env GOOS=darwin GOARCH=arm64 go build -ldflags="-X 'k8f/cmd.tversion=${{ steps.version.outputs.version }}'" -o ./k8f_darwin_arm .
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
unsoop/k8f:latest
unsoop/k8f:${{ steps.version.outputs.version }}
- name: release
uses: actions/create-release@v1
id: create_release
with:
draft: false
prerelease: true
release_name: ${{ steps.version.outputs.version }}
tag_name: ${{ github.ref }}
body_path: ./.github/workflows/CHANGELOG.md
env:
GITHUB_TOKEN: ${{ github.token }}
- name: upload linux artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./k8f
asset_name: k8f
asset_content_type: text/plain
- name: upload Windows artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./k8f.exe
asset_name: k8f.exe
asset_content_type: text/plain
- name: upload Arm Mac artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./k8f_darwin_arm
asset_name: k8f_darwin-arm64
asset_content_type: text/plain
- name: upload Amd Mac artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./k8f_darwin_amd
asset_name: k8f_darwin-amd64
asset_content_type: text/plain