-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (96 loc) · 3.55 KB
/
Copy pathrelease.yml
File metadata and controls
109 lines (96 loc) · 3.55 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
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
build:
name: ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
archive: tar.gz
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
archive: tar.gz
cross: true
- target: x86_64-apple-darwin
# Cross-compile from Apple Silicon — the macos-14 runner's
# Xcode SDK ships the x86_64 toolchain, and GitHub's macos-13
# Intel pool is unreliable (queues can stall for hours).
os: macos-14
archive: tar.gz
- target: aarch64-apple-darwin
os: macos-14
archive: tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
archive: zip
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross toolchain
if: matrix.cross == true
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Strip (unix)
if: runner.os != 'Windows'
run: |
BIN=target/${{ matrix.target }}/release/md2any
if command -v strip >/dev/null 2>&1; then strip "$BIN" || true; fi
shell: bash
- name: Package (unix)
if: matrix.archive == 'tar.gz'
shell: bash
run: |
NAME="md2any-${GITHUB_REF_NAME}-${{ matrix.target }}"
mkdir -p "dist/$NAME"
cp "target/${{ matrix.target }}/release/md2any" "dist/$NAME/"
cp README.md LICENSE-MIT LICENSE-APACHE CHANGELOG.md HELP.md "dist/$NAME/" 2>/dev/null || true
tar -C dist -czf "dist/$NAME.tar.gz" "$NAME"
echo "ASSET=dist/$NAME.tar.gz" >> $GITHUB_ENV
- name: Package (windows)
if: matrix.archive == 'zip'
shell: pwsh
run: |
$NAME = "md2any-$env:GITHUB_REF_NAME-${{ matrix.target }}"
New-Item -ItemType Directory -Path "dist/$NAME" -Force | Out-Null
Copy-Item "target/${{ matrix.target }}/release/md2any.exe" "dist/$NAME/"
foreach ($f in @("README.md", "LICENSE-MIT", "LICENSE-APACHE", "CHANGELOG.md", "HELP.md")) {
if (Test-Path $f) { Copy-Item $f "dist/$NAME/" }
}
Compress-Archive -Path "dist/$NAME/*" -DestinationPath "dist/$NAME.zip"
echo "ASSET=dist/$NAME.zip" | Out-File -Append $env:GITHUB_ENV
- name: Upload to release
uses: softprops/action-gh-release@v2
with:
files: ${{ env.ASSET }}
# generate_release_notes intentionally off — we attach the
# CHANGELOG.md [x.y.z] section manually so re-runs don't
# clobber human-curated notes with auto-generated ones.
generate_release_notes: false
publish-crate:
name: Publish to crates.io
runs-on: ubuntu-latest
needs: build
if: ${{ vars.PUBLISH_CRATE == 'true' }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}