forked from One-Block-Org/Atupa
-
Notifications
You must be signed in to change notification settings - Fork 0
148 lines (129 loc) · 4.87 KB
/
Copy pathrelease.yml
File metadata and controls
148 lines (129 loc) · 4.87 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
# ─────────────────────────────────────────────────────────────────────────────
# Atupa Release — Automated Binary Compilation & Publishing
#
# Triggered when a new version tag (v*) is pushed.
# Performs a cross-platform matrix build (Linux, macOS, Windows),
# bundles the Studio frontend into the binary, and creates a GitHub Release.
# ─────────────────────────────────────────────────────────────────────────────
name: 🚀 Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
# ── Phase 1: Create the Release Draft ──────────────────────────────────────
create-release:
name: 📝 Create GitHub Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
with:
draft: true
prerelease: false
generate_release_notes: true
# ── Phase 2: Build Binaries (Matrix) ───────────────────────────────────────
build-binaries:
name: 🛠️ Build for ${{ matrix.target }}
needs: create-release
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
artifact_name: atupa-linux-x86_64
asset_name: atupa-linux-x86_64.tar.gz
- target: aarch64-apple-darwin
os: macos-latest
artifact_name: atupa-macos-arm64
asset_name: atupa-macos-arm64.tar.gz
- target: x86_64-apple-darwin
os: macos-latest
artifact_name: atupa-macos-x86_64
asset_name: atupa-macos-x86_64.tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
artifact_name: atupa-windows-x64
asset_name: atupa-windows-x64.zip
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache Rust build
uses: Swatinem/rust-cache@v2
with:
key: atupa-release-${{ matrix.target }}-${{ hashFiles('Cargo.lock') }}
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: 'studio/package-lock.json'
# 🎨 Studio Frontend must be built for the binary to embed it
- name: Build Atupa Studio
shell: bash
run: |
cd studio
npm install
npm run build
- name: Build Atupa CLI
shell: bash
run: cargo build --release --target ${{ matrix.target }} -p atupa
# 📦 Packaging
- name: Package Binary (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
cd target/${{ matrix.target }}/release
tar czf ../../../${{ matrix.asset_name }} atupa
cd ../../../
- name: Package Binary (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
cd target/${{ matrix.target }}/release
Compress-Archive -Path atupa.exe -DestinationPath ../../../${{ matrix.asset_name }}
cd ../../../
# 🚀 Upload to the release created in Phase 1
- name: Upload Asset to Release
uses: softprops/action-gh-release@v2
with:
files: ${{ matrix.asset_name }}
tag_name: ${{ github.ref_name }}
# ── Phase 3: Publish to Crates.io ──────────────────────────────────────────
publish-crates:
name: 📦 Publish to Crates.io
needs: build-binaries
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Publish Workspace
shell: bash
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
run: |
if [ -z "$CARGO_REGISTRY_TOKEN" ]; then
echo "⚠️ CRATES_IO_TOKEN not found. Skipping publish step."
exit 0
fi
./publish.sh