-
Notifications
You must be signed in to change notification settings - Fork 1
100 lines (88 loc) · 3.08 KB
/
Copy pathrelease-cli.yaml
File metadata and controls
100 lines (88 loc) · 3.08 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
name: Release CLI
on:
push:
tags:
- "rustypipe-cli/v*.*.*"
permissions:
contents: write
jobs:
build:
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
archive: tar.xz
- runner: ubuntu-latest
target: aarch64-unknown-linux-gnu
archive: tar.xz
- runner: macos-13
target: x86_64-apple-darwin
archive: tar.xz
- runner: macos-14
target: aarch64-apple-darwin
archive: tar.xz
- runner: windows-latest
target: x86_64-pc-windows-msvc
archive: zip
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Linux cross-compilation dependencies
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu pkg-config libssl-dev
- name: Build application
run: cargo build --release --package=rustypipe-cli --target ${{ matrix.target }}
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
- name: Prepare archive
shell: bash
if: matrix.archive == 'tar.xz'
run: |
CRATE_VERSION=$(echo '${{ github.ref_name }}' | awk 'BEGIN{RS="/"} NR==2{print}')
BIN="rustypipe"
mkdir -p dist
tar -cJf "dist/${BIN}-${CRATE_VERSION}-${{ matrix.target }}.tar.xz" \
-C "target/${{ matrix.target }}/release" "${BIN}"
- name: Prepare archive
if: matrix.archive == 'zip'
shell: pwsh
run: |
$version = ('${{ github.ref_name }}' -split '/')[1]
New-Item -ItemType Directory -Force -Path dist | Out-Null
Compress-Archive -Path "target/${{ matrix.target }}/release/rustypipe.exe" `
-DestinationPath "dist/rustypipe-$version-${{ matrix.target }}.zip"
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: rustypipe-cli-${{ matrix.target }}
path: dist/*
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Get variables
run: |
echo "CRATE=rustypipe-cli" >> "$GITHUB_ENV"
echo "CRATE_VERSION=$(echo '${{ github.ref_name }}' | awk 'BEGIN{RS="/"} NR==2{print}')" >> "$GITHUB_ENV"
{
echo 'CHANGELOG<<END_OF_FILE'
awk 'BEGIN{RS="(^|\n)## [^\n]+\n*"} NR==2 { print }' "cli/CHANGELOG.md"
echo END_OF_FILE
} >> "$GITHUB_ENV"
- name: Publish release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: "${{ env.CRATE }} ${{ env.CRATE_VERSION }}"
body: ${{ env.CHANGELOG }}
files: dist/*