Skip to content

Commit 9eb8e18

Browse files
committed
wip for workflow
1 parent 4dea544 commit 9eb8e18

File tree

1 file changed

+128
-0
lines changed

1 file changed

+128
-0
lines changed

.github/workflows/release.yml.todo

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
env:
9+
BIN_NAME: mnemonic-hasher
10+
11+
jobs:
12+
build:
13+
name: build (${{ matrix.target }})
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
# Linux (x86_64)
20+
- os: ubuntu-latest
21+
target: x86_64-unknown-linux-gnu
22+
archive: tar.gz
23+
# Windows (x86_64)
24+
- os: windows-latest
25+
target: x86_64-pc-windows-msvc
26+
archive: zip
27+
# macOS Apple Silicon (arm64)
28+
- os: macos-14
29+
target: aarch64-apple-darwin
30+
archive: tar.gz
31+
# macOS Intel (x86_64)
32+
- os: macos-13
33+
target: x86_64-apple-darwin
34+
archive: tar.gz
35+
36+
steps:
37+
- uses: actions/checkout@v4
38+
39+
# Install Rust toolchain + target
40+
- name: Install Rust
41+
uses: dtolnay/rust-toolchain@stable
42+
with:
43+
targets: ${{ matrix.target }}
44+
45+
# Install pnpm
46+
- name: Install PNPM & Node
47+
uses: pnpm/action-setup
48+
49+
# Cache build artifacts
50+
- name: Cache cargo
51+
uses: Swatinem/rust-cache@v2
52+
with:
53+
save-if: ${{ github.ref_type == 'tag' }}
54+
55+
# Install dependencies
56+
- name: Install pnpm dependencies
57+
run: pnpm install
58+
59+
# Build
60+
- name: Build (release)
61+
run: NO_STRIP=1 pnpm tauri build --target ${{ matrix.target }}
62+
63+
# Package: name like mnemonic-hasher-v1.2.3-target.ext
64+
- name: Prepare dist
65+
shell: bash
66+
# FIXME: This might need some work
67+
run: |
68+
set -eux
69+
VERSION="${GITHUB_REF_NAME}" # v1.2.3
70+
TARGET="${{ matrix.target }}"
71+
OUTDIR="src-tauri/target/release"
72+
DIST="dist"
73+
mkdir -p "$DIST"
74+
75+
BIN="${BIN_NAME}"
76+
# Windows binary has .exe
77+
if [[ "${{ runner.os }}" == "Windows" ]]; then
78+
BIN="${BIN}.exe"
79+
fi
80+
81+
# Try to strip (where available)
82+
if command -v strip >/dev/null 2>&1; then
83+
strip "${OUTDIR}/${BIN}" || true
84+
fi
85+
86+
PKG="${BIN_NAME}-${VERSION}-${TARGET}"
87+
mkdir -p "${PKG}"
88+
cp "README.md" "${PKG}/" || true
89+
cp "LICENSE"* "${PKG}/" || true
90+
cp "${OUTDIR}/${BIN}" "${PKG}/"
91+
92+
if [[ "${{ matrix.archive }}" == "tar.gz" ]]; then
93+
tar -czf "${DIST}/${PKG}.tar.gz" "${PKG}"
94+
else
95+
# zip (Windows)
96+
7z a "${DIST}/${PKG}.zip" "${PKG}" >/dev/null
97+
fi
98+
99+
echo "DIST_PATH=${DIST}" >> $GITHUB_ENV
100+
101+
- name: Upload artifact
102+
uses: actions/upload-artifact@v4
103+
with:
104+
name: ${{ matrix.target }}
105+
path: ${{ env.DIST_PATH }}/*
106+
107+
release:
108+
name: publish release
109+
needs: [build]
110+
runs-on: ubuntu-latest
111+
steps:
112+
- name: Download all build artifacts
113+
uses: actions/download-artifact@v4
114+
with:
115+
path: dist
116+
117+
- name: List files
118+
run: ls -R dist
119+
120+
- name: Create GitHub Release
121+
uses: softprops/action-gh-release@v2
122+
with:
123+
tag_name: ${{ github.ref_name }}
124+
name: ${{ github.ref_name }}
125+
draft: false
126+
prerelease: false
127+
files: |
128+
dist/**/*

0 commit comments

Comments
 (0)