-
Notifications
You must be signed in to change notification settings - Fork 0
157 lines (131 loc) · 5.08 KB
/
release.yml
File metadata and controls
157 lines (131 loc) · 5.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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: Release
on:
push:
tags:
- 'v*.*.*'
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
permissions:
contents: write
jobs:
build-release:
name: Build Release Binaries
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: database-replicator
asset_name: database-replicator-linux-x64-binary
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: database-replicator
asset_name: database-replicator-macos-x64-binary
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: database-replicator
asset_name: database-replicator-macos-arm64-binary
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: database-replicator.exe
asset_name: database-replicator-windows-x64.exe
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Patch Cargo.toml for Windows compatibility
if: matrix.os == 'windows-latest'
run: |
$content = Get-Content Cargo.toml -Raw
# The home crate v0.5.12 requires unstable edition2024
# Patch Cargo.toml to constrain home version for older tags
if ($content -notmatch 'home\s*=') {
$content = $content -replace '(\[dependencies\])', "`$1`nhome = `">=0.5.4, <0.5.12`" # Pin to avoid v0.5.12 which requires unstable edition2024"
Write-Host "Added home crate constraint to Cargo.toml"
} else {
Write-Host "home crate already specified in Cargo.toml"
}
# Enable bundled feature for rusqlite on Windows to avoid needing sqlite3.lib
# Use literal replacement - regex anchors don't work with CRLF line endings in PowerShell
if ($content -match 'rusqlite\s*=\s*"0\.30"' -and $content -notmatch 'rusqlite.*bundled') {
$content = $content -replace 'rusqlite\s*=\s*"0\.30"', 'rusqlite = { version = "0.30", features = ["bundled"] }'
Write-Host "Enabled bundled feature for rusqlite"
} else {
Write-Host "rusqlite already has features configured or bundled is enabled"
}
Set-Content Cargo.toml $content
Write-Host "Final Cargo.toml dependencies section:"
Get-Content Cargo.toml | Select-String -Pattern "rusqlite|home" -Context 0,0
shell: pwsh
- name: Build release binary
run: cargo build --release --target ${{ matrix.target }} --verbose
- name: Strip binary (Linux)
if: matrix.os == 'ubuntu-latest'
run: strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
- name: Strip binary (macOS)
if: matrix.os == 'macos-latest'
run: strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
- name: Rename binary (Unix)
if: matrix.os != 'windows-latest'
run: |
cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} ${{ matrix.asset_name }}
chmod +x ${{ matrix.asset_name }}
- name: Rename binary (Windows)
if: matrix.os == 'windows-latest'
run: |
copy target\${{ matrix.target }}\release\${{ matrix.artifact_name }} ${{ matrix.asset_name }}
shell: cmd
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: ${{ matrix.asset_name }}
if-no-files-found: error
create-release:
name: Create GitHub Release
needs: build-release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: release-artifacts
- name: List artifacts
run: |
ls -lR release-artifacts/
find release-artifacts/ -type f -exec chmod +x {} \;
- name: Generate release notes
run: |
VERSION=${GITHUB_REF#refs/tags/}
scripts/generate-release-notes.sh "${VERSION}" > release-notes.md
- name: Create Release
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION=${GITHUB_REF#refs/tags/}
gh release create "${VERSION}" --notes-file release-notes.md
ls -l release-artifacts/**/*
# Upload assets to existing release
gh release upload "${VERSION}" \
release-artifacts/**/*
publish-crates:
name: Publish to crates.io
needs: create-release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
cargo publish --no-verify