-
Notifications
You must be signed in to change notification settings - Fork 1
156 lines (131 loc) · 4.2 KB
/
Copy pathrelease.yml
File metadata and controls
156 lines (131 loc) · 4.2 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
name: Build and Release
on:
push:
branches: [ main, develop ]
tags: [ 'v*' ]
paths:
- 'cmd/**'
- 'internal/**'
- 'pkg/**'
- 'go.mod'
- 'go.sum'
pull_request:
branches: [ main ]
paths:
- 'cmd/**'
- 'internal/**'
- 'pkg/**'
- 'go.mod'
- 'go.sum'
env:
BINARY_NAME: gitlab-cli
jobs:
build:
name: Build Binary
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
# Linux
- os: ubuntu-latest
goos: linux
goarch: amd64
artifact_name: gitlab-cli-linux-amd64
- os: ubuntu-latest
goos: linux
goarch: arm64
artifact_name: gitlab-cli-linux-arm64
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: true
- name: Get version info
id: version
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
else
echo "version=dev-${GITHUB_SHA::8}" >> $GITHUB_OUTPUT
fi
echo "commit=${GITHUB_SHA::8}" >> $GITHUB_OUTPUT
echo "date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
- name: Build binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
go build \
-ldflags="-s -w -X main.Version=${{ steps.version.outputs.version }}" \
-o "${{ matrix.artifact_name }}" \
./cmd/gitlab-cli
- name: Generate checksum
run: |
if [[ "${{ matrix.os }}" == "macos-latest" ]]; then
shasum -a 256 "${{ matrix.artifact_name }}" > "${{ matrix.artifact_name }}.sha256"
else
sha256sum "${{ matrix.artifact_name }}" > "${{ matrix.artifact_name }}.sha256"
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: |
${{ matrix.artifact_name }}
${{ matrix.artifact_name }}.sha256
retention-days: 30
release:
name: Create Release
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist/
- name: Prepare release assets
run: |
mkdir -p release
find dist/ -type f -exec cp {} release/ \;
ls -lah release/
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: release/*
draft: false
prerelease: false
generate_release_notes: true
body: |
## GitLab CLI ${{ github.ref_name }}
GitLab 用户和项目自动化管理工具
### 安装
下载对应平台的二进制文件,解压后即可使用:
```bash
# Linux (amd64)
wget https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/gitlab-cli-linux-amd64
chmod +x gitlab-cli-linux-amd64
sudo mv gitlab-cli-linux-amd64 /usr/local/bin/gitlab-cli
# macOS (arm64, Apple Silicon)
wget https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/gitlab-cli-darwin-arm64
chmod +x gitlab-cli-darwin-arm64
sudo mv gitlab-cli-darwin-arm64 /usr/local/bin/gitlab-cli
```
### 验证安装
```bash
gitlab-cli --version
```
### 文档
- [快速开始](https://github.com/${{ github.repository }}/blob/main/docs/QUICKSTART.md)
- [完整文档](https://github.com/${{ github.repository }}/blob/main/docs/README.md)
- [架构设计](https://github.com/${{ github.repository }}/blob/main/docs/ARCHITECTURE.md)