Skip to content

Commit ab0f73c

Browse files
feat: 添加构建脚本
1 parent 3231bef commit ab0f73c

5 files changed

Lines changed: 449 additions & 21 deletions

File tree

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Auto detect text files and perform LF normalization
2-
* text=auto
2+
* text=lf

.github/workflows/build.yml

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
name: build(mise)
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
default: 'latest'
8+
description: 'Package version'
9+
type: string
10+
required: true
11+
schedule:
12+
- cron: '0 20 * * *'
13+
14+
permissions:
15+
contents: write
16+
packages: write
17+
18+
env:
19+
app_name: 'mise'
20+
app_repo: 'jdx/mise'
21+
22+
jobs:
23+
check:
24+
runs-on: ubuntu-slim
25+
outputs:
26+
app_version: ${{ steps.get-version.outputs.app_version }}
27+
app_build: ${{ steps.check-release.outputs.app_build }}
28+
steps:
29+
- uses: actions/checkout@v6
30+
31+
- name: Get Version
32+
id: get-version
33+
run: |
34+
if [ "${{ github.event_name }}" = "schedule" ] || [ "${{ github.event.inputs.version }}" = "latest" ]; then
35+
app_version=$(curl -s "https://api.github.com/repos/${{ env.app_repo }}/releases/latest" | jq -r .tag_name)
36+
else
37+
app_version=${{ github.event.inputs.version }}
38+
fi
39+
if [ -z "${app_version}" ] || [ "${app_version}" == "null" ]; then
40+
echo "Failed to get version"
41+
exit 1
42+
fi
43+
44+
echo "app_version=${app_version}" >> $GITHUB_ENV
45+
echo "app_version=${app_version}" >> $GITHUB_OUTPUT
46+
echo ""
47+
echo "========== Build Args =========="
48+
echo "app_version=${app_version}"
49+
50+
- name: Check Release
51+
id: check-release
52+
run: |
53+
gh release view ${app_version} -R ${{ github.repository }} | grep ${app_name}-${app_version}-linux-loong64.tar.gz >/dev/null 2>&1 || echo "app_build=1" >> $GITHUB_OUTPUT
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
57+
build-tarball-linux:
58+
if: needs.check.outputs.app_build == '1'
59+
runs-on: ubuntu-latest
60+
needs: check
61+
env:
62+
app_version: ${{ needs.check.outputs.app_version }}
63+
strategy:
64+
fail-fast: false
65+
matrix:
66+
include:
67+
- name: linux-loong64
68+
target: loongarch64-unknown-linux-gnu
69+
- name: linux-loong64-musl
70+
target: loongarch64-unknown-linux-musl
71+
72+
steps:
73+
- uses: actions/checkout@v6
74+
with:
75+
repository: ${{ env.app_repo }}
76+
ref: ${{ env.app_version }}
77+
78+
- name: Install cross
79+
uses: taiki-e/install-action@v2
80+
with:
81+
tool: cross
82+
83+
- name: cache crates
84+
id: cache-crates
85+
uses: actions/cache@v4
86+
with:
87+
path: ~/.cargo/registry/cache
88+
key: cargo-registry-${{ hashFiles('**/Cargo.lock') }}
89+
restore-keys: cargo-registry
90+
91+
- name: Prepare
92+
run: |
93+
wget -qO - https://github.com/${{ github.repository }}/raw/refs/heads/main/patch_loong64.patch | patch -p1
94+
95+
- name: build-tarball ${{matrix.target}}
96+
uses: nick-fields/retry@v3
97+
with:
98+
max_attempts: 3
99+
timeout_minutes: 100
100+
command: scripts/build-tarball.sh ${{matrix.target}}
101+
102+
- uses: actions/upload-artifact@v4
103+
with:
104+
name: tarball-${{matrix.target}}
105+
path: |
106+
dist/mise-*.tar.xz
107+
dist/mise-*.tar.gz
108+
dist/mise-*.tar.zst
109+
if-no-files-found: error
110+
111+
- uses: taiki-e/install-action@v2
112+
with: { tool: cargo-cache }
113+
114+
- if: steps.cache-crates.outputs.cache-hit != 'true'
115+
run: cargo cache --autoclean
116+
117+
dockerhub:
118+
if: needs.check.outputs.app_build == '1'
119+
runs-on: ${{ matrix.platform.os }}
120+
needs: check
121+
env:
122+
app_version: ${{ needs.check.outputs.app_version }}
123+
strategy:
124+
fail-fast: false
125+
matrix:
126+
platform:
127+
- os: ubuntu-latest
128+
tag_suffix: loong64
129+
platform: linux/loong64
130+
131+
steps:
132+
- uses: actions/checkout@v6
133+
with:
134+
repository: ${{ env.app_repo }}
135+
ref: ${{ env.app_version }}
136+
137+
- name: Prepare
138+
run: |
139+
platform="${{ matrix.platform.platform }}"
140+
echo "PLATFORM_PAIR=${platform//\//-}" >> "$GITHUB_ENV"
141+
wget -qO - https://github.com/${{ github.repository }}/raw/refs/heads/main/patch_loong64.patch | patch -p1
142+
sed -i "s|FROM rust@.* AS|FROM ghcr.io/loong64/rust@trixie AS|g" packaging/mise/Dockerfile
143+
144+
- name: Setup QEMU
145+
uses: docker/setup-qemu-action@v3
146+
147+
- name: Set up Docker Buildx
148+
uses: docker/setup-buildx-action@v3
149+
150+
- name: Login to GitHub Container Registry
151+
uses: docker/login-action@v3
152+
with:
153+
registry: ghcr.io
154+
username: ${{ github.repository_owner }}
155+
password: ${{ secrets.GITHUB_TOKEN }}
156+
157+
- name: Build and Push base image
158+
uses: docker/build-push-action@v6
159+
with:
160+
context: .
161+
platforms: ${{ matrix.platform.platform }}
162+
push: true
163+
tags: |
164+
ghcr.io/${{ github.repository }}:${{ env.app_version }}
165+
166+
release:
167+
if: needs.check.outputs.app_build == '1'
168+
runs-on: ubuntu-24.04
169+
needs:
170+
- check
171+
- build-tarball-linux
172+
env:
173+
app_version: ${{ needs.check.outputs.app_version }}
174+
steps:
175+
- uses: actions/checkout@v6
176+
177+
- name: Download release
178+
uses: actions/download-artifact@v8
179+
with:
180+
pattern: tarball-*
181+
path: dist
182+
merge-multiple: true
183+
184+
- name: Create release
185+
env:
186+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
187+
run: |
188+
TAG_NAME="${{ env.app_version }}"
189+
gh release create "${TAG_NAME}" \
190+
--generate-notes \
191+
--title "${TAG_NAME}" \
192+
dist/*

LICENSE

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
MIT License
2-
3-
Copyright (c) 2026 吴小白
4-
5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
11-
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1+
MIT License
2+
3+
Copyright (c) 2026 吴小白
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.

0 commit comments

Comments
 (0)