-
Notifications
You must be signed in to change notification settings - Fork 35
140 lines (122 loc) · 4.22 KB
/
release-rust.yml
File metadata and controls
140 lines (122 loc) · 4.22 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
name: Release Rust Binaries
# Trigger: push a tag v*.*.* or v*.*.*-* (e.g. v0.1.0, v0.1.0-rc1), or run manually from Actions tab.
on:
push:
tags:
- 'v*.*.*'
- 'v*.*.*-*'
workflow_dispatch:
inputs:
tag:
description: 'Release tag (e.g. v0.1.0-rc1); must already exist'
required: true
type: string
jobs:
test:
name: Test gate
if: github.event_name != 'workflow_dispatch'
uses: ./.github/workflows/test-gate.yml
secrets: inherit
build:
name: Build ${{ matrix.target }}
needs: [test]
if: always() && (needs.test.result == 'success' || needs.test.result == 'skipped')
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
strip_bin: strip
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
cross: true
strip_bin: aarch64-linux-gnu-strip
- target: x86_64-apple-darwin
os: macos-latest
strip_bin: strip
- target: aarch64-apple-darwin
os: macos-latest
strip_bin: strip
- target: x86_64-pc-windows-msvc
os: windows-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }}
- uses: dtolnay/rust-toolchain@1.85.0
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
workspaces: memoria
shared-key: release-${{ matrix.target }}
- name: Install build deps (x86_64-linux-musl)
if: matrix.target == 'x86_64-unknown-linux-musl'
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
- name: Install strip tool (aarch64-linux-musl)
if: matrix.target == 'aarch64-unknown-linux-musl'
run: |
sudo apt-get update
sudo apt-get install -y binutils-aarch64-linux-gnu
- name: Install cross
if: matrix.cross
uses: taiki-e/install-action@cross
- name: Build (cross)
if: matrix.cross
working-directory: memoria
env:
SQLX_OFFLINE: "true"
run: cross build --release -p memoria-cli --target ${{ matrix.target }}
- name: Build (native)
if: ${{ !matrix.cross }}
working-directory: memoria
env:
SQLX_OFFLINE: "true"
run: cargo build --release -p memoria-cli --target ${{ matrix.target }}
- name: Package (unix)
if: runner.os != 'Windows'
run: |
mkdir -p dist
cp memoria/target/${{ matrix.target }}/release/memoria dist/ 2>/dev/null || true
${{ matrix.strip_bin }} dist/memoria 2>/dev/null || true
cd dist && tar czf ../memoria-${{ matrix.target }}.tar.gz *
- name: Package (windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
New-Item -ItemType Directory -Force dist
Copy-Item "memoria/target/${{ matrix.target }}/release/memoria.exe" dist/
Compress-Archive -Path dist/* -DestinationPath "memoria-${{ matrix.target }}.zip"
- uses: actions/upload-artifact@v4
with:
name: memoria-${{ matrix.target }}
path: memoria-${{ matrix.target }}.*
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Generate checksums
run: |
cd artifacts
find . \( -name '*.tar.gz' -o -name '*.zip' \) -exec cp {} . \;
sha256sum *.tar.gz *.zip > SHA256SUMS.txt
cat SHA256SUMS.txt
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
files: |
artifacts/*.tar.gz
artifacts/*.zip
artifacts/SHA256SUMS.txt
generate_release_notes: true
prerelease: ${{ contains(github.ref_name, '-rc') || contains(github.ref_name, '-beta') || contains(github.ref_name, '-alpha') }}