-
Notifications
You must be signed in to change notification settings - Fork 100
142 lines (123 loc) Β· 4.79 KB
/
release.yml
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
name: Release Binary
on:
workflow_dispatch:
permissions:
contents: write
env:
# Ultimately, we shouldn't ignore warnings.
# We need to pass it as an ENV because inlining doesn't work on Windows.
RUSTFLAGS: -A dead_code
# Need these guys for cross-compilation
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-gnu-gcc
jobs:
build_and_test:
name: Build & Test for ${{ matrix.config.target }}
strategy:
matrix:
config:
- { os: ubuntu-latest, target: x86_64-unknown-linux-gnu }
- { os: ubuntu-latest, target: aarch64-unknown-linux-gnu }
- { os: macos-latest, target: x86_64-apple-darwin }
- { os: macos-latest, target: aarch64-apple-darwin }
- { os: windows-latest, target: x86_64-pc-windows-msvc }
- { os: windows-latest, target: aarch64-pc-windows-msvc }
runs-on: ${{ matrix.config.os }}
outputs:
artifact_url: ${{ steps.upload-artifacts.outputs.artifact-url }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.config.target }}
- uses: Swatinem/rust-cache@v2
id: rust-cache
# The Aarch64 Linux is a special snowflake, we need to install its toolchain
- name: Install arm64 toolchain
if: matrix.config.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
# running containers via `services` only works on linux
# https://github.com/actions/runner/issues/1866
- name: π Setup postgres
uses: ikalnytskyi/action-setup-postgres@v7
- name: π§ͺ Run Tests
run: cargo test --release
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres
- name: π οΈ Run Build
run: cargo build -p pglt_cli --release --target ${{ matrix.config.target }}
# windows is a special snowflake too, it saves binaries as .exe
- name: π¦ Name the Binary
if: matrix.config.os == 'windows-latest'
run: |
mkdir dist
cp target/${{ matrix.config.target }}/release/pglt.exe ./dist/pglt_${{ matrix.config.target }}
- name: π¦ Name the Binary
if: matrix.config.os != 'windows-latest'
run: |
mkdir dist
cp target/${{ matrix.config.target }}/release/pglt ./dist/pglt_${{ matrix.config.target }}
# It is not possible to return the artifacts from the matrix jobs individually: Matrix outputs overwrite each other.
# A common workaround is to upload and download the resulting artifacts.
- name: π Upload Artifacts
id: upload-artifacts
uses: actions/upload-artifact@v4
with:
name: pglt_${{ matrix.config.target }}
path: ./dist/pglt_*
# The default compression level is 6; this took the binary down from 350 to 330MB.
# It is recommended to use a lower level for binaries, since the compressed result is not much smaller,
# and the higher levels of compression take much longer.
compression-level: 2
if-no-files-found: error
create_changelog_and_release:
runs-on: ubuntu-latest
needs: build_and_test # make sure that tests & build work correctly
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
# we need all commits to create a changelog
fetch-depth: 0
- name: π Create Changelog
uses: orhun/git-cliff-action@v3
id: create_changelog
with:
config: cliff.toml
args: --bump --latest
env:
GITHUB_REPO: ${{ github.repository }}
- name: π Download Artifacts
uses: actions/download-artifact@v4
id: download
with:
merge-multiple: true
pattern: pglt_*
- name: π Create Release
uses: softprops/action-gh-release@v2
id: create-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: ${{ steps.create_changelog.outputs.content }}
tag_name: ${{ steps.create_changelog.outputs.version }}
files: |
pglt_*
docs/schemas/latest/schema.json
fail_on_unmatched_files: true
draft: true
- name: β
Output Link to Worflow Summary
run: |
{
echo "# π Release completed!"
echo ""
echo "Here is the URL to the Release Draft:"
echo ""
echo "[Link](${{ steps.create-release.outputs.url }})"
echo ""
} >> "$GITHUB_STEP_SUMMARY"