Skip to content

Commit b2b8a6a

Browse files
committed
init
0 parents  commit b2b8a6a

35 files changed

+7217
-0
lines changed

.github/workflows/release.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
name: Build ${{ matrix.target }}
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
- os: ubuntu-latest
20+
target: x86_64-unknown-linux-gnu
21+
bin_ext: ""
22+
- os: ubuntu-latest
23+
target: x86_64-unknown-linux-musl
24+
bin_ext: ""
25+
- os: windows-latest
26+
target: x86_64-pc-windows-msvc
27+
bin_ext: ".exe"
28+
- os: macos-latest
29+
target: aarch64-apple-darwin
30+
bin_ext: ""
31+
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
36+
- name: Setup Rust toolchain
37+
uses: actions-rust-lang/setup-rust-toolchain@v1
38+
with:
39+
toolchain: stable
40+
targets: ${{ matrix.target }}
41+
42+
- name: Install musl tools
43+
if: matrix.target == 'x86_64-unknown-linux-musl'
44+
run: |
45+
sudo apt-get update
46+
sudo apt-get install -y musl-tools
47+
48+
- name: Build
49+
run: cargo build --release --locked --target ${{ matrix.target }}
50+
51+
- name: Prepare artifact
52+
id: prepare
53+
shell: bash
54+
run: |
55+
set -euo pipefail
56+
BIN="pgcopy"
57+
VERSION="${GITHUB_REF_NAME}"
58+
TARGET="${{ matrix.target }}"
59+
EXT="${{ matrix.bin_ext }}"
60+
OUT="dist/${BIN}-${VERSION}-${TARGET}${EXT}"
61+
mkdir -p dist
62+
cp "target/${TARGET}/release/${BIN}${EXT}" "${OUT}"
63+
if [ "${EXT}" = "" ]; then
64+
chmod +x "${OUT}"
65+
fi
66+
67+
if [ "${EXT}" = ".exe" ]; then
68+
ARCHIVE="dist/${BIN}-${VERSION}-${TARGET}.zip"
69+
(
70+
cd dist
71+
7z a "$(basename "${ARCHIVE}")" "$(basename "${OUT}")"
72+
)
73+
else
74+
ARCHIVE="dist/${BIN}-${VERSION}-${TARGET}.tar.gz"
75+
tar -C dist -czf "${ARCHIVE}" "$(basename "${OUT}")"
76+
fi
77+
78+
rm -f "${OUT}"
79+
echo "archive=${ARCHIVE}" >> "${GITHUB_OUTPUT}"
80+
81+
- name: Upload artifact
82+
uses: actions/upload-artifact@v4
83+
with:
84+
name: ${{ matrix.target }}
85+
path: ${{ steps.prepare.outputs.archive }}
86+
87+
release:
88+
name: Publish GitHub Release
89+
needs: build
90+
runs-on: ubuntu-latest
91+
92+
steps:
93+
- name: Download artifacts
94+
uses: actions/download-artifact@v4
95+
with:
96+
path: artifacts
97+
98+
- name: Create Release and upload assets
99+
uses: softprops/action-gh-release@v2
100+
with:
101+
tag_name: ${{ github.ref_name }}
102+
name: ${{ github.ref_name }}
103+
files: |
104+
artifacts/**/*.tar.gz
105+
artifacts/**/*.zip

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/target
2+
config.toml
3+
*.tar.zst

0 commit comments

Comments
 (0)