-
Notifications
You must be signed in to change notification settings - Fork 0
176 lines (151 loc) · 6.83 KB
/
Copy pathci.yml
File metadata and controls
176 lines (151 loc) · 6.83 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: Build && Prerelease
on:
push:
jobs:
common:
runs-on: ubuntu-latest
outputs:
go-version: ${{ steps.go.outputs.version }}
commit-hash: ${{ steps.common.outputs.hash }}
commit-message: ${{ steps.common.outputs.message }}
steps:
- name: get latest go version
id: go
run: |
echo version=$(curl -s https://raw.githubusercontent.com/actions/go-versions/update-versions-manifest-file/versions-manifest.json | grep -oE '"version": "[0-9]{1}.[0-9]{1,}(.[0-9]{1,})?"' | head -1 | cut -d':' -f2 | sed 's/ //g; s/"//g') >> $GITHUB_OUTPUT
- uses: actions/checkout@v4.1.1
with:
fetch-depth: 0
- name: get short commit id
id: common
run: |
echo hash=$(git rev-parse --short HEAD) >> $GITHUB_OUTPUT
echo message=$(git log --pretty=format:%s HEAD -1) >> $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
needs:
- common
strategy:
matrix:
jobs:
# linux
- { goos: linux, goarch: 386, output: 386 }
- { goos: linux, goarch: s390x, output: s390x }
- { goos: linux, goarch: riscv64, output: riscv64 }
- { goos: linux, goarch: arm64, output: arm64 }
- { goos: linux, goarch: loong64, abi: 1, output: loong64-abi1 }
- { goos: linux, goarch: loong64, abi: 2, output: loong64-abi2 }
- { goos: linux, goarch: arm, goarm: 5, output: armv5 }
- { goos: linux, goarch: arm, goarm: 6, output: armv6 }
- { goos: linux, goarch: arm, goarm: 7, output: armv7 }
- { goos: linux, goarch: amd64, goamd64: v1, output: amd64 }
- { goos: linux, goarch: amd64, goamd64: v3, output: amd64v3 }
- { goos: linux, goarch: mips, output: mips }
- { goos: linux, goarch: mips, gomips: softfloat, output: mips-softfloat }
- { goos: linux, goarch: mips, gomips: hardfloat, output: mips-hardfloat }
- { goos: linux, goarch: mipsle, output: mipsle }
- { goos: linux, goarch: mips64, output: mips64 }
- { goos: linux, goarch: mips64, gomips: softfloat, output: mips64-softfloat }
- { goos: linux, goarch: mips64, gomips: hardfloat, output: mips64-hardfloat }
- { goos: linux, goarch: mips64le, output: mips64le }
env:
GOOS: ${{ matrix.jobs.goos }}
GOARM: ${{ matrix.jobs.goarm }}
GOARCH: ${{ matrix.jobs.goarch }}
GOAMD64: ${{ matrix.jobs.goamd64 }}
GOMIPS: ${{ matrix.jobs.gomips }}
CGO_ENABLED: ${{ matrix.jobs.goos == 'android' && 1 || 0 }}
VERSION: ${{ needs.common.outputs.commit-hash }}
SUFFIX: ${{ matrix.jobs.goos == 'windows' && '.exe' || '' }}
steps:
- uses: actions/checkout@v4.1.1
with:
fetch-depth: 0
- name: get short commit id
id: version
run: |
echo VERSION=$(git rev-parse --short HEAD) >> $GITHUB_ENV
echo message=$(git log --pretty=format:%s HEAD -1) >> $GITHUB_OUTPUT
- name: set up go1.23 loongarch abi1
if: ${{ matrix.jobs.goarch == 'loong64' && matrix.jobs.abi == '1' }}
run: |
wget -q https://github.com/MetaCubeX/loongarch64-golang/releases/download/1.22.4/go1.22.4.linux-amd64-abi${{ matrix.jobs.abi }}.tar.gz -O linux-amd64.tar.gz
sudo tar zxf linux-amd64.tar.gz -C /usr/local
echo "/usr/local/go/bin" >> $GITHUB_PATH
- name: setup go
uses: actions/setup-go@v5.0.0
if: ${{ matrix.jobs.goarch != 'loong64' || matrix.jobs.abi != '1' }}
with:
go-version: ${{ needs.common.outputs.go-version }}
# modify from https://github.com/restic/restic/issues/4636#issuecomment-1896455557
# this patch file only works on golang1.23.x
# that means after golang1.24 release it must be changed
# see: https://github.com/MetaCubeX/go/commits/release-branch.go1.23/
# revert:
# 693def151adff1af707d82d28f55dba81ceb08e1: "crypto/rand,runtime: switch RtlGenRandom for ProcessPrng"
# 7c1157f9544922e96945196b47b95664b1e39108: "net: remove sysSocket fallback for Windows 7"
# 48042aa09c2f878c4faa576948b07fe625c4707a: "syscall: remove Windows 7 console handle workaround"
# a17d959debdb04cd550016a3501dd09d50cd62e7: "runtime: always use LoadLibraryEx to load system libraries"
- name: revert golang1.23 commit for windows7/8
if: ${{ matrix.jobs.goos == 'windows' }}
run: |
cd $(go env GOROOT)
curl https://github.com/MetaCubeX/go/commit/9ac42137ef6730e8b7daca016ece831297a1d75b.diff | patch --verbose -p 1
curl https://github.com/MetaCubeX/go/commit/21290de8a4c91408de7c2b5b68757b1e90af49dd.diff | patch --verbose -p 1
curl https://github.com/MetaCubeX/go/commit/6a31d3fa8e47ddabc10bd97bff10d9a85f4cfb76.diff | patch --verbose -p 1
curl https://github.com/MetaCubeX/go/commit/69e2eed6dd0f6d815ebf15797761c13f31213dd6.diff | patch --verbose -p 1
- name: Setup NDK
if: ${{ matrix.jobs.goos == 'android' }}
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r27
- name: Setup CC ENV
if: ${{ matrix.jobs.goos == 'android' }}
run: echo "CC=${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/${{ matrix.jobs.ndk }}-clang" >> $GITHUB_ENV
- name: build
run: go build -o git-proxy-${{ env.GOOS }}-${{ matrix.jobs.output }}${{ env.SUFFIX }} -v -trimpath -ldflags "-s -w -buildid=" main.go
- name: upload
uses: actions/upload-artifact@v4.1.0
with:
name: git-proxy-${{ env.VERSION }}-${{ env.GOOS }}-${{ matrix.jobs.output }}
path: git-proxy-${{ env.GOOS }}-${{ matrix.jobs.output }}${{ env.SUFFIX }}
compression-level: 9
upload-release:
permissions: write-all
needs:
- common
- build
runs-on: ubuntu-latest
steps:
- name: Download all workflow run artifacts
uses: actions/download-artifact@v4
with:
path: bin/
merge-multiple: true
- name: Delete current release assets
uses: 8Mi-Tech/delete-release-assets-action@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: Prerelease
deleteOnlyFromDrafts: false
- name: Tag Repo
uses: richardsimko/update-tag@v1
with:
tag_name: Prerelease
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
cat > release.txt << 'EOF'
${{ needs.common.outputs.commit-hash }} ${{ needs.common.outputs.commit-message }}
EOF
- name: Upload Prerelease
uses: softprops/action-gh-release@v1
if: ${{ success() }}
with:
tag_name: Prerelease
files: |
bin/*
prerelease: true
generate_release_notes: true
body_path: release.txt