Skip to content

Commit dafc3fb

Browse files
authored
chore: add GitHub release workflow (#47)
1 parent bd3d830 commit dafc3fb

5 files changed

Lines changed: 128 additions & 4 deletions

File tree

.github/workflows/release.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
include:
18+
- os: macos-14
19+
target: aarch64-apple-darwin
20+
- os: ubuntu-latest
21+
target: x86_64-unknown-linux-musl
22+
23+
env:
24+
ASSET_BASENAME: gitee-${{ github.ref_name }}-${{ matrix.target }}
25+
26+
steps:
27+
- name: Check out repository
28+
uses: actions/checkout@v4
29+
30+
- name: Read Rust version
31+
id: rust-version
32+
run: echo "version=$(awk '/^rust / { print $2 }' .tool-versions)" >> "$GITHUB_OUTPUT"
33+
34+
- name: Install Rust toolchain
35+
run: |
36+
rustup toolchain install "${{ steps.rust-version.outputs.version }}" --profile minimal
37+
rustup default "${{ steps.rust-version.outputs.version }}"
38+
rustup target add "${{ matrix.target }}"
39+
40+
- name: Install musl tools
41+
if: matrix.target == 'x86_64-unknown-linux-musl'
42+
run: |
43+
sudo apt-get update
44+
sudo apt-get install -y musl-tools
45+
46+
- name: Build release binary
47+
run: cargo build --locked --release --target "${{ matrix.target }}"
48+
49+
- name: Package release archive
50+
run: |
51+
mkdir -p "dist/${ASSET_BASENAME}"
52+
cp "target/${{ matrix.target }}/release/gitee" "dist/${ASSET_BASENAME}/gitee"
53+
cp LICENSE README.md README_CN.md "dist/${ASSET_BASENAME}/"
54+
tar -C dist -czf "dist/${ASSET_BASENAME}.tar.gz" "${ASSET_BASENAME}"
55+
56+
- name: Upload release archive
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: ${{ matrix.target }}
60+
path: dist/${{ env.ASSET_BASENAME }}.tar.gz
61+
if-no-files-found: error
62+
63+
publish:
64+
needs: build
65+
runs-on: ubuntu-latest
66+
67+
steps:
68+
- name: Download release archives
69+
uses: actions/download-artifact@v4
70+
with:
71+
path: release-assets
72+
merge-multiple: true
73+
74+
- name: Generate checksums
75+
run: |
76+
cd release-assets
77+
shasum -a 256 *.tar.gz > "gitee-${GITHUB_REF_NAME}-checksums.txt"
78+
79+
- name: Create or update draft GitHub release
80+
uses: softprops/action-gh-release@v2
81+
with:
82+
draft: true
83+
generate_release_notes: true
84+
overwrite_files: true
85+
fail_on_unmatched_files: true
86+
working_directory: release-assets
87+
files: |
88+
*.tar.gz
89+
gitee-${{ github.ref_name }}-checksums.txt

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Changelog
2+
3+
The changelog can be found on the releases page.

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ name = "gitee-cli"
33
version = "0.1.0"
44
edition = "2024"
55
license = "MIT"
6+
description = "Agent-first CLI for gitee.com workflows"
7+
readme = "README.md"
8+
repository = "https://github.com/hex2dec/gitee-cli"
9+
homepage = "https://github.com/hex2dec/gitee-cli"
10+
rust-version = "1.94.0"
11+
keywords = ["gitee", "cli", "git", "automation"]
12+
categories = ["command-line-utilities"]
613

714
[[bin]]
815
name = "gitee"

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,22 @@ Use `gitee-cli` if you want:
5353
- write operations that accept flags, files, or stdin instead of prompts
5454
- predictable behavior that can be scripted safely
5555

56-
## Start Here
56+
## Install
5757

58-
Today the project is built from source.
58+
Tagged GitHub releases publish prebuilt binaries for:
59+
60+
- Apple Silicon macOS: `aarch64-apple-darwin`
61+
- Linux x86_64: `x86_64-unknown-linux-musl`
62+
63+
Download the matching archive from the GitHub Releases page, extract it, and
64+
place `gitee` somewhere on your `PATH`.
65+
66+
Each release also includes `gitee-<version>-checksums.txt`.
67+
68+
## Build From Source
69+
70+
If you need a development build or a platform outside the published release
71+
assets, build from source:
5972

6073
Build the binary locally:
6174

README_CN.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,21 @@ gitee help --json
5353
- 写操作通过参数、文件或 stdin 提供内容,而不是依赖交互式提示
5454
- 行为稳定、便于脚本安全调用
5555

56-
## 从这里开始
56+
## 安装
5757

58-
当前项目通过源码构建。
58+
打了 tag 的 GitHub Release 会提供以下预构建二进制:
59+
60+
- Apple Silicon macOS:`aarch64-apple-darwin`
61+
- Linux x86_64:`x86_64-unknown-linux-musl`
62+
63+
从 GitHub Releases 页面下载对应平台的压缩包,解压后将 `gitee` 放到你的
64+
`PATH` 中即可。
65+
66+
每个 release 还会额外提供 `gitee-<version>-checksums.txt`
67+
68+
## 从源码构建
69+
70+
如果你需要开发版,或者目标平台不在当前发布资产范围内,可以从源码构建:
5971

6072
本地构建二进制:
6173

0 commit comments

Comments
 (0)