-
Notifications
You must be signed in to change notification settings - Fork 3
156 lines (130 loc) · 5.13 KB
/
Copy pathrust.yml
File metadata and controls
156 lines (130 loc) · 5.13 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
name: Build
on:
push:
branches: ["*"]
env:
BIN_NAME: "rs-postgres"
permissions:
contents: write
jobs:
get-version:
name: Get version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Get crate version
id: get-version
run: |
version=$(grep -m1 '^version =' Cargo.toml | cut -d '"' -f2)
echo "version=${version}" >> $GITHUB_OUTPUT
echo "Using version: ${version}"
build:
name: Build ${{ matrix.target }}
needs: get-version
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# linux
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact: linux-x86_64
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
artifact: linux-arm64
use-cross: true
# mac
- os: macos-latest
target: x86_64-apple-darwin
artifact: macos-x86_64
- os: macos-latest
target: aarch64-apple-darwin
artifact: macos-arm64
# win
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact: windows-x64.exe
steps:
- uses: actions/checkout@v4
- name: Setup cross-compile
if: matrix.use-cross
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
- name: Install rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}
toolchain: stable
profile: minimal
- name: Build
shell: bash
run: |
cargo build --release --target ${{ matrix.target }}
mkdir -p release
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
EXT=".exe"
else
EXT=""
fi
cp "target/${{ matrix.target }}/release/$BIN_NAME$EXT" "release/${{ matrix.artifact }}"
- name: Upload bins
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: release/${{ matrix.artifact }}
release:
name: Create release
needs: [get-version, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download bins
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Get all commits
id: changelog
run: |
VERSION="${{ needs.get-version.outputs.version }}"
VERSION_COMMIT=$(git log --reverse --pretty=format:%H -S "version = \"$VERSION\"" -- Cargo.toml | head -1)
if [ -z "$VERSION_COMMIT" ]; then
echo "Version commit not found, using all commits"
COMMITS=$(git log --pretty=format:"- %s%n %b" | sed '/^ $/d')
else
echo "Found version commit: $VERSION_COMMIT"
COMMITS=$(git log --pretty=format:"- %s%n %b" $VERSION_COMMIT^..HEAD | sed '/^ $/d')
fi
if [ -n "$COMMITS" ]; then
DELIMITER=$(openssl rand -hex 16)
echo "changelog<<$DELIMITER" >> $GITHUB_OUTPUT
echo "### Changelog" >> $GITHUB_OUTPUT
echo "$COMMITS" >> $GITHUB_OUTPUT
echo "$DELIMITER" >> $GITHUB_OUTPUT
else
echo "changelog=No changes for this version" >> $GITHUB_OUTPUT
fi
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.get-version.outputs.version }}
name: "v${{ needs.get-version.outputs.version }}"
body: |
Build for version ${{ needs.get-version.outputs.version }}.
${{ steps.changelog.outputs.changelog }}
Thank you for using Rs-Postgres!
files: |
artifacts/linux-x86_64
artifacts/linux-arm64
artifacts/macos-x86_64
artifacts/macos-arm64
artifacts/windows-x64.exe
draft: false
prerelease: false