Skip to content

Commit 5903362

Browse files
committed
Add cli-release workflow (#971)
Also optimize the size of the release build.
1 parent 215d3d6 commit 5903362

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

.github/workflows/cli-release.yml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: 🚀 Release Trunk
2+
on:
3+
push:
4+
paths:
5+
- ".github/workflows/cli-release.yml"
6+
- "cli/**"
7+
- "!cli/README.md"
8+
- "!cli/.gitignore"
9+
permissions:
10+
contents: write
11+
defaults:
12+
run:
13+
shell: bash
14+
working-directory: ./cli/
15+
jobs:
16+
release:
17+
name: 🦀 ${{ matrix.toolchain }} on linux/${{ matrix.arch }}
18+
runs-on:
19+
# https://runs-on.com/runners/linux/
20+
- runs-on=${{ github.run_id }}-${{ matrix.toolchain }}-${{ matrix.arch }}
21+
- runner=large-${{ matrix.arch }}
22+
- cpu=8
23+
- ram=16
24+
continue-on-error: ${{ matrix.toolchain == 'nightly' }}
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
arch: [amd64, arm64]
29+
toolchain: [stable, beta, nightly]
30+
steps:
31+
- uses: actions/checkout@v4
32+
- name: Setup Rust
33+
uses: actions-rust-lang/setup-rust-toolchain@v1
34+
with:
35+
toolchain: ${{ matrix.toolchain }}
36+
cache-key: ${{ matrix.arch }}
37+
components: rustfmt, clippy, llvm-tools
38+
- name: Build Binary
39+
run: cargo build --release
40+
- name: Get the Version
41+
if: env.VERSION == ''
42+
run: echo "VERSION=$(grep "^version" Cargo.toml | sed -r 's/version[^"]+"([^"]+).*/\1/')" >> $GITHUB_ENV
43+
- name: Determine Archive Name
44+
run: |
45+
echo "ARCHIVE=trunk-v$VERSION-linux-${{ matrix.arch }}" >> $GITHUB_ENV
46+
- name: Package Archive
47+
run: |
48+
set -ex
49+
printf "Packaging %s\n" "$ARCHIVE"
50+
mkdir "$ARCHIVE"
51+
cp target/release/trunk "$ARCHIVE"/
52+
cp {README.md,../LICENSE} "$ARCHIVE"/
53+
tar czvf "$ARCHIVE.tar.gz" "$ARCHIVE"
54+
- name: Upload Artifacts
55+
uses: actions/upload-artifact@v4
56+
with:
57+
path: "${{ env.ARCHIVE }}.*"
58+
name: "${{ env.ARCHIVE }}"
59+
overwrite: true
60+
if: matrix.toolchain == 'stable' && github.ref_name == 'main'
61+
- name: Publish GitHub Release
62+
uses: softprops/action-gh-release@v2
63+
with:
64+
draft: true
65+
name: "Release ${{ env.VERSION }}"
66+
files: "trunk-*"
67+
if: matrix.toolchain == 'stable' && github.ref_name == 'main'

cli/Cargo.toml

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pg-trunk"
3-
version = "0.16.4"
3+
version = "0.16.5"
44
edition = "2021"
55
authors = ["Ian Stanton", "Vinícius Miguel", "David E. Wheeler"]
66
description = "A package manager for PostgreSQL extensions"
@@ -67,3 +67,11 @@ git2 = "0.17.0"
6767
predicates = "2.1.5"
6868
tempfile = "3"
6969
mockcmd = { version = "0.0.1", features = ["test"] }
70+
71+
# https://github.com/johnthagen/min-sized-rust
72+
[profile.release]
73+
strip = true
74+
opt-level = "s"
75+
lto = true
76+
codegen-units = 1
77+
panic = "abort"

0 commit comments

Comments
 (0)