-
Notifications
You must be signed in to change notification settings - Fork 56
141 lines (125 loc) · 4.39 KB
/
Copy pathrelease-hypecli.yml
File metadata and controls
141 lines (125 loc) · 4.39 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
name: Release hypecli Binary
on:
push:
tags:
- "hypecli-v*"
branches:
- main
workflow_dispatch:
inputs:
tag:
description: "Release tag (e.g., hypecli-v1.0.0)"
required: true
type: string
env:
CARGO_TERM_COLOR: always
jobs:
create-release:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
release_id: ${{ steps.create_release.outputs.id }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
tag: ${{ steps.extract_version.outputs.tag }}
steps:
- uses: actions/checkout@v4
- name: Extract version
id: extract_version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ github.event.inputs.tag }}"
VERSION=${TAG#hypecli-v}
elif [ "${{ github.ref_type }}" = "tag" ]; then
TAG="${{ github.ref_name }}"
VERSION=${TAG#hypecli-v}
else
# Push to main branch
TAG="hypecli-main-latest"
VERSION="main-${{ github.sha }}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "is_main_build=${{ github.ref_type != 'tag' && github.event_name != 'workflow_dispatch' }}" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.extract_version.outputs.tag }}
name: hypecli ${{ steps.extract_version.outputs.version }}
draft: false
prerelease: ${{ steps.extract_version.outputs.is_main_build == 'true' }}
make_latest: ${{ steps.extract_version.outputs.is_main_build != 'true' }}
build:
needs: create-release
permissions:
contents: write
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name: hypecli-linux-x86_64
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
name: hypecli-linux-aarch64
- target: x86_64-apple-darwin
os: macos-latest
name: hypecli-macos-x86_64
- target: aarch64-apple-darwin
os: macos-latest
name: hypecli-macos-aarch64
- target: x86_64-pc-windows-msvc
os: windows-latest
name: hypecli-windows-x86_64.exe
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross-compilation dependencies (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu musl-tools pkg-config
- name: Configure cross-compilation (Linux aarch64)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
echo '[target.aarch64-unknown-linux-gnu]' >> ~/.cargo/config.toml
echo 'linker = "aarch64-linux-gnu-gcc"' >> ~/.cargo/config.toml
- name: Build binary
run: |
cd hypecli
cargo build --release --target ${{ matrix.target }}
- name: Package binary (Unix)
if: matrix.os != 'windows-latest'
run: |
cd hypecli/target/${{ matrix.target }}/release
tar czf ${{ matrix.name }}.tar.gz hypecli
mv ${{ matrix.name }}.tar.gz ../../../..
- name: Package binary (Windows)
if: matrix.os == 'windows-latest'
run: |
cd hypecli/target/${{ matrix.target }}/release
7z a ${{ matrix.name }}.zip hypecli.exe
move ${{ matrix.name }}.zip ../../../..
- name: Upload Release Asset (Unix)
if: matrix.os != 'windows-latest'
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.create-release.outputs.tag }}
files: ./${{ matrix.name }}.tar.gz
- name: Upload Release Asset (Windows)
if: matrix.os == 'windows-latest'
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.create-release.outputs.tag }}
files: ./${{ matrix.name }}.zip