Skip to content

Commit 9ab9cee

Browse files
committed
ci: add release please
1 parent 3d65627 commit 9ab9cee

File tree

4 files changed

+123
-121
lines changed

4 files changed

+123
-121
lines changed

.github/workflows/release-please.yaml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
10+
name: release-please
11+
12+
jobs:
13+
release-please:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: google-github-actions/release-please-action@v3
17+
with:
18+
release-type: rust
19+
package-name: psdm
20+
include-v-in-tag: false
21+
token: ${{ secrets.PAT }}

.github/workflows/release.yaml

+45-58
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,16 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- name: Checkout sources
18-
uses: actions/checkout@v2
18+
uses: actions/checkout@v4
1919

20-
- name: Install stable toolchain
21-
uses: actions-rs/toolchain@v1
22-
with:
23-
profile: minimal
24-
toolchain: stable
25-
override: true
20+
- name: Install toolchain
21+
uses: dtolnay/rust-toolchain@stable
2622

2723
- name: Run `cargo publish` - upload to crates.io
28-
uses: actions-rs/cargo@v1
2924
env:
3025
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
3126
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32-
with:
33-
command: publish
27+
run: cargo publish
3428

3529
upload:
3630
name: ${{ matrix.job.os }} (${{ matrix.job.target }})
@@ -39,26 +33,28 @@ jobs:
3933
fail-fast: false
4034
matrix:
4135
job:
42-
- { os: ubuntu-latest, target: x86_64-unknown-linux-musl, use-cross: true }
36+
- { os: ubuntu-20.04, target: x86_64-unknown-linux-musl, use-cross: true }
37+
- { os: ubuntu-latest, target: x86_64-unknown-linux-gnu, use-cross: true }
38+
- { os: ubuntu-latest, target: aarch64-unknown-linux-musl, use-cross: true }
39+
- { os: ubuntu-latest, target: i686-unknown-linux-musl, use-cross: true }
4340
- { os: macos-latest, target: x86_64-apple-darwin, use-cross: true }
41+
- { os: macos-latest, target: aarch64-apple-darwin, use-cross: true }
4442
steps:
4543
- name: Checkout source code
46-
uses: actions/checkout@v2
44+
uses: actions/checkout@v4
4745

4846
- name: Extract crate information
4947
shell: bash
5048
run: |
51-
echo "PROJECT_NAME=${{ github.event.repository.name }}" >> $GITHUB_ENV
49+
echo "PROJECT_NAME=psdm" >> $GITHUB_ENV
5250
echo "PROJECT_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> $GITHUB_ENV
5351
echo "PROJECT_MAINTAINER=$(sed -n 's/^authors = \["\(.*\)"\]/\1/p' Cargo.toml)" >> $GITHUB_ENV
5452
echo "PROJECT_HOMEPAGE=$(sed -n 's/^homepage = "\(.*\)"/\1/p' Cargo.toml)" >> $GITHUB_ENV
55-
- name: Install Rust toolchain
56-
uses: actions-rs/toolchain@v1
53+
54+
- name: Install toolchain
55+
uses: dtolnay/rust-toolchain@stable
5756
with:
58-
toolchain: stable
59-
target: ${{ matrix.job.target }}
60-
override: true
61-
profile: minimal # minimal component installation (ie, no documentation)
57+
targets: ${{ matrix.job.target }}
6258

6359
- name: Show version information (Rust, cargo, GCC)
6460
shell: bash
@@ -69,48 +65,32 @@ jobs:
6965
rustup default
7066
cargo -V
7167
rustc -V
72-
- name: Build
73-
uses: actions-rs/cargo@v1
68+
69+
- name: Install cross
70+
uses: taiki-e/install-action@v2
7471
with:
75-
use-cross: ${{ matrix.job.use-cross }}
76-
command: build
77-
args: --release --target=${{ matrix.job.target }}
72+
tool: cross
7873

79-
- name: Strip debug information from executable
80-
id: strip
74+
- name: Build with cross
75+
run: cross build --release --target=${{ matrix.job.target }}
76+
77+
- name: Set binary name & path
78+
id: bin
8179
shell: bash
8280
run: |
8381
# Figure out suffix of binary
8482
EXE_suffix=""
85-
# Figure out what strip tool to use if any
86-
STRIP="strip"
83+
case ${{ matrix.job.target }} in
84+
*-pc-windows-*) EXE_suffix=".exe" ;;
85+
esac;
86+
8787
# Setup paths
88-
BIN_DIR="${{ env.CICD_INTERMEDIATES_DIR }}/stripped-release-bin/"
89-
mkdir -p "${BIN_DIR}"
9088
BIN_NAME="${{ env.PROJECT_NAME }}${EXE_suffix}"
91-
BIN_PATH="${BIN_DIR}/${BIN_NAME}"
92-
# Copy the release build binary to the result location
93-
cp "target/${{ matrix.job.target }}/release/${BIN_NAME}" "${BIN_DIR}"
94-
# Also strip if possible
95-
if [ -n "${STRIP}" ]; then
96-
"${STRIP}" "${BIN_PATH}"
97-
fi
98-
# Let subsequent steps know where to find the (stripped) bin
99-
echo ::set-output name=BIN_PATH::${BIN_PATH}
100-
echo ::set-output name=BIN_NAME::${BIN_NAME}
101-
- name: Set testing options
102-
id: test-options
103-
shell: bash
104-
run: |
105-
unset CARGO_TEST_OPTIONS
106-
unset CARGO_TEST_OPTIONS ; case ${{ matrix.job.target }} in arm-* | aarch64-*) CARGO_TEST_OPTIONS="--bin ${PROJECT_NAME}" ;; esac;
107-
echo ::set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS}
108-
- name: Run tests
109-
uses: actions-rs/cargo@v1
110-
with:
111-
use-cross: ${{ matrix.job.use-cross }}
112-
command: test
113-
args: --target=${{ matrix.job.target }} ${{ steps.test-options.outputs.CARGO_TEST_OPTIONS}}
89+
BIN_PATH="target/${{ matrix.job.target }}/release/${BIN_NAME}"
90+
91+
# Let subsequent steps know where to find the binary
92+
echo "BIN_PATH=${BIN_PATH}" >> $GITHUB_OUTPUT
93+
echo "BIN_NAME=${BIN_NAME}" >> $GITHUB_OUTPUT
11494
11595
- name: Create tarball
11696
id: package
@@ -119,23 +99,28 @@ jobs:
11999
PKG_suffix=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) PKG_suffix=".zip" ;; esac;
120100
PKG_BASENAME=${PROJECT_NAME}-${PROJECT_VERSION}-${{ matrix.job.target }}
121101
PKG_NAME=${PKG_BASENAME}${PKG_suffix}
122-
echo ::set-output name=PKG_NAME::${PKG_NAME}
102+
echo "PKG_NAME=${PKG_NAME}" >> $GITHUB_OUTPUT
123103
PKG_STAGING="${{ env.CICD_INTERMEDIATES_DIR }}/package"
124104
ARCHIVE_DIR="${PKG_STAGING}/${PKG_BASENAME}/"
125105
mkdir -p "${ARCHIVE_DIR}"
106+
126107
# Binary
127-
cp "${{ steps.strip.outputs.BIN_PATH }}" "$ARCHIVE_DIR"
108+
cp "${{ steps.bin.outputs.BIN_PATH }}" "$ARCHIVE_DIR"
109+
128110
# README, LICENSE and CHANGELOG files
129111
cp "README.md" "LICENSE" "CHANGELOG.md" "$ARCHIVE_DIR"
112+
130113
# base compressed package
131114
pushd "${PKG_STAGING}/" >/dev/null
132115
case ${{ matrix.job.target }} in
133116
*-pc-windows-*) 7z -y a "${PKG_NAME}" "${PKG_BASENAME}"/* | tail -2 ;;
134117
*) tar czf "${PKG_NAME}" "${PKG_BASENAME}"/* ;;
135118
esac;
136119
popd >/dev/null
120+
137121
# Let subsequent steps know where to find the compressed package
138-
echo ::set-output name=PKG_PATH::"${PKG_STAGING}/${PKG_NAME}"
122+
echo "PKG_PATH=${PKG_STAGING}/${PKG_NAME}" >> $GITHUB_OUTPUT
123+
139124
- name: "Artifact upload: tarball"
140125
uses: actions/upload-artifact@master
141126
with:
@@ -147,12 +132,14 @@ jobs:
147132
shell: bash
148133
run: |
149134
unset IS_RELEASE ; if [[ $GITHUB_REF =~ ^refs/tags/[0-9].* ]]; then IS_RELEASE='true' ; fi
150-
echo ::set-output name=IS_RELEASE::${IS_RELEASE}
135+
echo "IS_RELEASE=${IS_RELEASE}" >> $GITHUB_OUTPUT
136+
151137
- name: Publish archives and packages
152-
uses: softprops/action-gh-release@59c3b4891632ff9a897f99a91d7bc557467a3a22 # https://github.com/softprops/action-gh-release/issues/139
138+
uses: softprops/action-gh-release@v2
153139
if: steps.is-release.outputs.IS_RELEASE
154140
with:
155141
files: |
156142
${{ steps.package.outputs.PKG_PATH }}
157143
env:
158144
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
145+

0 commit comments

Comments
 (0)