Repository navigation
95 lines (82 loc) · 2.5 KB
/
Copy pathrelease.yml
File metadata and controls
95 lines (82 loc) · 2.5 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
name: Release smcp-cli
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Release tag (e.g., v0.1.0)'
required: false
type: string
permissions:
contents: write
jobs:
build-release:
name: Build ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
name: smcp-linux-amd64
- os: macos-latest
target: x86_64-apple-darwin
name: smcp-darwin-amd64
- os: macos-latest
target: aarch64-apple-darwin
name: smcp-darwin-arm64
- os: windows-latest
target: x86_64-pc-windows-msvc
name: smcp-windows-amd64.exe
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: cargo build --release --target ${{ matrix.target }} --bin smcp
- name: Rename binary (Unix)
if: matrix.os != 'windows-latest'
run: cp target/${{ matrix.target }}/release/smcp ${{ matrix.name }}
- name: Rename binary (Windows)
if: matrix.os == 'windows-latest'
run: copy target\${{ matrix.target }}\release\smcp.exe ${{ matrix.name }}
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: ${{ matrix.name }}
create-release:
needs: build-release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.tag != ''
steps:
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Flatten artifacts
run: |
mkdir -p release
find artifacts -type f -exec mv {} release/ \;
ls -la release/
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.inputs.tag || github.ref_name }}
files: release/*
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}