-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (129 loc) · 5.39 KB
/
release.yml
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
144
name: Release
on:
push:
branches:
- main
jobs:
build:
name: 'Publish'
runs-on: ubuntu-latest
steps:
# Checkout updated source code
- uses: actions/checkout@v4
name: Checkout Code
- name: Tag
id: autotagger
uses: butlerlogic/action-autotag@stable
with:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# If the new version/tag is a pre-release (i.e. 1.0.0-beta.1), create
# an environment variable indicating it is a prerelease.
- name: Pre-release
if: steps.autotagger.outputs.tagname != ''
run: |
if [[ "${{ steps.autotagger.output.version }}" == *"-"* ]]; then echo "::set-env IS_PRERELEASE=true";else echo "::set-env IS_PRERELEASE=''";fi
- name: Release
id: create_release
if: steps.autotagger.outputs.tagname != ''
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.autotagger.outputs.tagname }}
release_name: ${{ steps.autotagger.outputs.tagname }}
body: ${{ steps.autotagger.outputs.tagmessage }}
draft: false
prerelease: env.IS_PRERELEASE != ''
- name: Setup Go
if: steps.create_release.outputs.id != ''
uses: actions/setup-go@v4
with:
go-version: '^1.21.0' # The Go version to download (if necessary) and use.
- uses: actions/setup-node@v3
if: steps.create_release.outputs.id != ''
name: Setup Node.js
with:
node-version: lts/*
# - name: Install Quikdev Go Tool
# run: npm i -g @quikdev/go
# if: steps.create_release.outputs.id != ''
- name: Build Windows
if: steps.create_release.outputs.id != ''
run: |
name=$(grep -E '"name":' package.json | awk -F '"' '{print $4}')
version=$(grep -E '"version":' package.json | awk -F '"' '{print $4}')
description=$(grep -E '"description":' package.json | awk -F '"' '{print $4}')
echo "Name: $name"
echo "Version: $version"
echo "Description: $description"
mkdir -p ./bin/win32
mkdir -p ./release
# qgo build
go build -ldflags "-X 'main.name=$name' -X 'main.version=$version' -X 'main.description=$description'" -o ./bin/win32/dh-util.exe dh-util.go
chmod +x ./bin/win32/dh-util.exe
tar -czvf ./release/dh-util-win32-x64.tar.gz ./bin/win32
zip -jr ./release/dh-util-win32-x64.zip ./bin/win32
env:
GOOS: windows
- name: Build macOS
if: steps.create_release.outputs.id != ''
run: |
name=$(grep -E '"name":' package.json | awk -F '"' '{print $4}')
version=$(grep -E '"version":' package.json | awk -F '"' '{print $4}')
description=$(grep -E '"description":' package.json | awk -F '"' '{print $4}')
echo "Name: $name"
echo "Version: $version"
echo "Description: $description"
mkdir -p ./bin/darwin
mkdir -p ./release
# qgo build
go build -ldflags "-X 'main.name=$PACKAGE_NAME' -X 'main.version=$PACKAGE_VERSION' -X 'main.description=$PACKAGE_DESCRIPTION'" -o ./bin/darwin/dh-util dh-util.go
chmod +x ./bin/darwin/dh-util
tar -czvf ./release/dh-util-macos-x64.tar.gz ./bin/darwin
zip -jr ./release/dh-util-macos-x64.zip ./bin/darwin
env:
GOOS: darwin
- name: Build Linux
if: steps.create_release.outputs.id != ''
run: |
name=$(grep -E '"name":' package.json | awk -F '"' '{print $4}')
version=$(grep -E '"version":' package.json | awk -F '"' '{print $4}')
description=$(grep -E '"description":' package.json | awk -F '"' '{print $4}')
echo "Name: $name"
echo "Version: $version"
echo "Description: $description"
mkdir -p ./bin/linux
mkdir -p ./release
# qgo build
go build -tags netgo -installsuffix netgo -ldflags "-X 'main.name=$name' -X 'main.version=$version' -X 'main.description=$description' -w -extldflags '-static'" -o ./bin/linux/dh-util dh-util.go
chmod +x ./bin/darwin/dh-util
tar -czvf ./release/dh-util-linux-x64.tar.gz ./bin/linux
zip -jr ./release/dh-util-linux-x64.zip ./bin/linux
env:
GOOS: linux
GOARCH: amd64
# Upload tarballs to the release.
- name: Upload Tarball Release Artifacts
uses: AButler/[email protected]
if: steps.create_release.outputs.id != ''
with:
files: './release/*.tar.gz'
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: ${{ steps.autotagger.outputs.tagname }}
# Upload zip files to the release.
- name: Upload Zip Release Artifacts
uses: AButler/[email protected]
if: steps.create_release.outputs.id != ''
with:
files: './release/*.zip'
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: ${{ steps.autotagger.outputs.tagname }}
- name: Temp
run: ls -l ./release
- name: Rollback Release
if: failure() && steps.create_release.outputs.id != ''
uses: author/action-rollback@stable
with:
tag: ${{ steps.autotagger.outputs.tagname }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}