|
1 | 1 | name: build |
2 | 2 |
|
3 | 3 | on: |
4 | | - release: |
5 | 4 | workflow_dispatch: |
6 | | - |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: "Tag name of release" |
| 8 | + |
7 | 9 | jobs: |
8 | 10 | build: |
9 | 11 | strategy: |
10 | | - matrix: |
11 | | - # Include amd64 on all platforms. |
12 | | - goos: [ windows, linux, darwin ] |
13 | | - goarch: [ amd64, 386 ] |
14 | | - goamd64: [ v1, v3 ] |
15 | | - exclude: |
16 | | - # Exclude GOAMD64 v3 on i386 |
17 | | - - goarch: 386 |
18 | | - goamd64: v3 |
19 | | - # Exclude i386 on darwin and dragonfly. |
20 | | - - goarch: 386 |
21 | | - goos: dragonfly |
22 | | - - goarch: 386 |
23 | | - goos: darwin |
24 | | - include: |
25 | | - # BEGIN macOS ARM64 |
26 | | - - goos: darwin |
27 | | - goarch: arm64 |
28 | | - # END macOS ARM64 |
29 | | - # BEGIN Linux ARM 5 6 7 |
30 | | - - goos: linux |
31 | | - goarch: arm |
32 | | - goarm: 7 |
33 | | - - goos: linux |
34 | | - goarch: arm |
35 | | - goarm: 6 |
36 | | - - goos: linux |
37 | | - goarch: arm |
38 | | - goarm: 5 |
39 | | - # END Linux ARM 5 6 7 |
40 | | - # BEGIN Android ARM 8 |
41 | | - - goos: android |
42 | | - goarch: arm64 |
43 | | - # END Android ARM 8 |
44 | | - # Windows ARM |
45 | | - - goos: windows |
46 | | - goarch: arm64 |
47 | | - - goos: windows |
48 | | - goarch: arm |
49 | | - goarm: 7 |
50 | | - # BEGIN Other architectures |
51 | | - # BEGIN riscv64 & ARM64 |
52 | | - - goos: linux |
53 | | - goarch: arm64 |
54 | | - - goos: linux |
55 | | - goarch: riscv64 |
56 | | - # END riscv64 & ARM64 |
57 | | - # BEGIN MIPS |
58 | | - - goos: linux |
59 | | - goarch: mips64 |
60 | | - - goos: linux |
61 | | - goarch: mips64le |
62 | | - - goos: linux |
63 | | - goarch: mipsle |
64 | | - - goos: linux |
65 | | - goarch: mips |
66 | | - # END MIPS |
67 | | - # BEGIN LOONGARCH |
68 | | - - goos: linux |
69 | | - goarch: loong64 |
70 | | - # END LOONGARCH |
71 | | - # BEGIN S390X |
72 | | - - goos: linux |
73 | | - goarch: s390x |
74 | | - # END S390X |
75 | | - # END Other architectures |
76 | | - |
| 12 | + matrix: |
| 13 | + # Include amd64 on all platforms. |
| 14 | + goos: [ windows, linux, darwin ] |
| 15 | + goarch: [ amd64, 386 ] |
| 16 | + goamd64: [ v1, v3 ] |
| 17 | + exclude: |
| 18 | + # Exclude GOAMD64 v3 on i386 |
| 19 | + - goarch: 386 |
| 20 | + goamd64: v3 |
| 21 | + # Exclude i386 on darwin and dragonfly. |
| 22 | + - goarch: 386 |
| 23 | + goos: dragonfly |
| 24 | + - goarch: 386 |
| 25 | + goos: darwin |
| 26 | + include: |
| 27 | + # BEGIN macOS ARM64 |
| 28 | + - goos: darwin |
| 29 | + goarch: arm64 |
| 30 | + # END macOS ARM64 |
| 31 | + # BEGIN Linux ARM 5 6 7 |
| 32 | + - goos: linux |
| 33 | + goarch: arm |
| 34 | + goarm: 7 |
| 35 | + - goos: linux |
| 36 | + goarch: arm |
| 37 | + goarm: 6 |
| 38 | + - goos: linux |
| 39 | + goarch: arm |
| 40 | + goarm: 5 |
| 41 | + # END Linux ARM 5 6 7 |
| 42 | + # BEGIN Android ARM 8 |
| 43 | + - goos: android |
| 44 | + goarch: arm64 |
| 45 | + # END Android ARM 8 |
| 46 | + # Windows ARM |
| 47 | + - goos: windows |
| 48 | + goarch: arm64 |
| 49 | + - goos: windows |
| 50 | + goarch: arm |
| 51 | + goarm: 7 |
| 52 | + # BEGIN Other architectures |
| 53 | + # BEGIN riscv64 & ARM64 |
| 54 | + - goos: linux |
| 55 | + goarch: arm64 |
| 56 | + - goos: linux |
| 57 | + goarch: riscv64 |
| 58 | + # END riscv64 & ARM64 |
| 59 | + # BEGIN MIPS |
| 60 | + - goos: linux |
| 61 | + goarch: mips64 |
| 62 | + - goos: linux |
| 63 | + goarch: mips64le |
| 64 | + - goos: linux |
| 65 | + goarch: mipsle |
| 66 | + - goos: linux |
| 67 | + goarch: mips |
| 68 | + # END MIPS |
| 69 | + # BEGIN LOONGARCH |
| 70 | + - goos: linux |
| 71 | + goarch: loong64 |
| 72 | + # END LOONGARCH |
| 73 | + # BEGIN S390X |
| 74 | + - goos: linux |
| 75 | + goarch: s390x |
| 76 | + # END S390X |
| 77 | + # END Other architectures |
| 78 | + |
77 | 79 | runs-on: ubuntu-latest |
78 | 80 | env: |
79 | 81 | GOOS: ${{ matrix.goos }} |
80 | 82 | GOARCH: ${{ matrix.goarch }} |
81 | 83 | GOARM: ${{ matrix.goarm }} |
82 | 84 | GOAMD64: ${{ matrix.goamd64 }} |
83 | 85 | CGO_ENABLED: 0 |
84 | | - |
| 86 | + BUILD_NAME: ZBProxy-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.goarm }}${{ matrix.goamd64 }}${{ matrix.goos == 'windows' && '.exe' || '' }} |
| 87 | + |
85 | 88 | steps: |
86 | | - - uses: actions/checkout@v4 |
| 89 | + - uses: actions/checkout@v4 |
87 | 90 |
|
88 | | - - name: Set up Go |
89 | | - uses: actions/setup-go@v5 |
90 | | - with: |
91 | | - go-version: ^1.20 |
92 | | - check-latest: true |
| 91 | + - name: Set up Go |
| 92 | + uses: actions/setup-go@v5 |
| 93 | + with: |
| 94 | + go-version: ^1.20 |
| 95 | + check-latest: true |
93 | 96 |
|
94 | | - - name: Tidy up Go Modules |
95 | | - run: go mod tidy |
| 97 | + - name: Tidy up Go Modules |
| 98 | + run: go mod tidy |
96 | 99 |
|
97 | | - - name: Get Git Commit Hash |
98 | | - id: hash |
99 | | - run: echo "git_hash=$(git rev-parse --short HEAD || echo "unknown version")" >> $GITHUB_OUTPUT |
| 100 | + - name: Get Git Commit Hash |
| 101 | + id: hash |
| 102 | + run: echo "git_hash=$(git rev-parse --short HEAD || echo "unknown version")" >> $GITHUB_OUTPUT |
100 | 103 |
|
101 | | - - name: Build |
102 | | - run: go build -v -trimpath -ldflags '-X "github.com/layou233/zbproxy/v3/version.CommitHash=${{ steps.hash.outputs.git_hash }}" -s -w -buildid=' -o ZBProxy-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.goarm }}${{ matrix.goamd64 }} ./cmd/zbproxy |
| 104 | + - name: Build |
| 105 | + run: go build -v -trimpath -ldflags '-X "github.com/layou233/zbproxy/v3/version.CommitHash=${{ steps.hash.outputs.git_hash }}" -s -w -buildid=' -o $BUILD_NAME ./cmd/zbproxy |
103 | 106 |
|
104 | | - - name: Handle for Windows Build |
105 | | - if: ${{ env.GOOS == 'windows' }} |
106 | | - run: mv ZBProxy-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.goarm }}${{ matrix.goamd64 }} ZBProxy-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.goarm }}${{ matrix.goamd64 }}.exe |
| 107 | + - name: Upload Build Artifact |
| 108 | + uses: actions/upload-artifact@v4 |
| 109 | + with: |
| 110 | + name: ${{ env.BUILD_NAME }} |
| 111 | + path: ${{ env.BUILD_NAME }} |
107 | 112 |
|
108 | | - - name: Upload a Non-Windows Build Artifact |
109 | | - uses: actions/upload-artifact@v4 |
110 | | - if: ${{ env.GOOS != 'windows' }} |
111 | | - with: |
112 | | - name: ZBProxy-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.goarm }}${{ matrix.goamd64 }} |
113 | | - path: ZBProxy-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.goarm }}${{ matrix.goamd64 }} |
| 113 | + Publish: |
| 114 | + permissions: write-all |
| 115 | + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version }} |
| 116 | + needs: [ build ] |
| 117 | + runs-on: ubuntu-latest |
| 118 | + steps: |
| 119 | + - uses: actions/download-artifact@v4 |
| 120 | + with: |
| 121 | + path: bin/ |
| 122 | + merge-multiple: true |
114 | 123 |
|
115 | | - - name: Upload a Windows Build Artifact |
116 | | - uses: actions/upload-artifact@v4 |
117 | | - if: ${{ env.GOOS == 'windows' }} |
118 | | - with: |
119 | | - name: ZBProxy-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.goarm }}${{ matrix.goamd64 }}.exe |
120 | | - path: ZBProxy-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.goarm }}${{ matrix.goamd64 }}.exe |
| 124 | + - name: Upload Release |
| 125 | + uses: softprops/action-gh-release@v2 |
| 126 | + if: ${{ success() }} |
| 127 | + with: |
| 128 | + tag_name: ${{ github.event.inputs.version }} |
| 129 | + files: bin/* |
| 130 | + prerelease: true |
0 commit comments