-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (74 loc) · 2.17 KB
/
build_and_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
# Following Github Actions builds and releases Golang package github.com/groovy-sky/azbusqueue/v2
# for Linux and Windows architectures
# and publishes it to Github Releases
name: Build and Release
on:
push:
tags: ["v*"]
paths-ignore:
- '**/*.md'
pull_request:
branches: [main]
paths-ignore:
- '**/*.md'
env:
PKG_NAME: "azbusqueue"
PKG_VER: "${GITHUB_REF#refs/tags/}"
OUTPUT_DIR: out
jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
matrix:
goos: ["linux","windows"]
goarch: ["arm", "arm64", "386", "amd64"]
go: ["^1.18.1"]
fail-fast: true
name: Go ${{ matrix.go }} ${{ matrix.goos }} ${{ matrix.goarch }} build
steps:
- uses: actions/checkout@v3
- name: Setup go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
echo ${{ env.PKG_VER }}
mkdir ${{ env.OUTPUT_DIR }}
ls -la
go build -o ${{ env.OUTPUT_DIR }}/${{ env.PKG_NAME }}_${{ env.PKG_VER }}_${{ matrix.goos }}_${{ matrix.goarch }}
- name: Upload result
uses: actions/upload-artifact@v3
with:
name: ${{ env.PKG_NAME }}
path: ${{ env.OUTPUT_DIR }}/
create-release:
needs:
- build-linux
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: ${{ env.PKG_NAME }}
path: ${{ github.workspace }}/${{ env.PKG_NAME }}
- name: Archive release files
run: |
zip -jrm ${{ env.PKG_NAME }}.zip ${{ env.PKG_NAME }}/
- name: Create release
if: github.event_name != 'pull_request'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
release=${{ env.PKG_NAME }}.zip
tag="${{ env.PKG_VER }}"
gh release create "${tag}" --notes "${release}"
ls -la
gh release upload "${tag}" "${release}"