Skip to content

Commit 7bc3d8c

Browse files
committed
chore: fix release workflow and enable merge for release-please
1 parent 449ddff commit 7bc3d8c

File tree

2 files changed

+193
-163
lines changed

2 files changed

+193
-163
lines changed

.github/workflows/release.yml

Lines changed: 177 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -1,156 +1,177 @@
1-
name: Release
2-
3-
permissions:
4-
contents: write
5-
pull-requests: write
6-
7-
on:
8-
push:
9-
branches:
10-
- main
11-
12-
env:
13-
CARGO_TERM_COLOR: always
14-
15-
jobs:
16-
release-please:
17-
runs-on: ubuntu-latest
18-
outputs:
19-
release_created: ${{ steps.release.outputs.release_created }}
20-
tag_name: ${{ steps.release.outputs.tag_name }}
21-
steps:
22-
- name: Run release-please
23-
id: release
24-
uses: googleapis/release-please-action@v4
25-
with:
26-
token: ${{ secrets.GITHUB_TOKEN }}
27-
28-
upload-assets:
29-
name: Upload assets
30-
needs: release-please
31-
if: ${{ needs.release-please.outputs.release_created }}
32-
strategy:
33-
fail-fast: false
34-
matrix:
35-
include:
36-
- target: x86_64-unknown-linux-gnu
37-
os: ubuntu-latest
38-
- target: x86_64-pc-windows-msvc
39-
os: windows-latest
40-
- target: aarch64-pc-windows-msvc
41-
os: windows-latest
42-
- target: x86_64-apple-darwin
43-
os: macos-latest
44-
- target: aarch64-apple-darwin
45-
os: macos-latest
46-
47-
runs-on: ${{ matrix.os }}
48-
steps:
49-
- name: Checkout code
50-
uses: actions/checkout@v4
51-
52-
- name: Upload CLI binary
53-
uses: taiki-e/upload-rust-binary-action@v1
54-
with:
55-
bin: resl
56-
package: resl-cli
57-
target: ${{ matrix.target }}
58-
archive: resl-${{ needs.release-please.outputs.tag_name }}-$target
59-
tar: unix
60-
zip: windows
61-
token: ${{ secrets.GITHUB_TOKEN }}
62-
63-
- name: Install Rust toolchain
64-
uses: actions-rust-lang/setup-rust-toolchain@v1
65-
with:
66-
toolchain: stable
67-
target: ${{ matrix.target }}
68-
69-
- name: Build FFI library
70-
run: cargo build --release --package resl-ffi --target ${{ matrix.target }}
71-
72-
- name: Create FFI package structure
73-
shell: bash
74-
run: |
75-
mkdir -p dist/ffi/lib
76-
mkdir -p dist/ffi/include
77-
78-
- name: Copy FFI library files (Linux)
79-
if: matrix.target == 'x86_64-unknown-linux-gnu'
80-
run: |
81-
cp target/${{ matrix.target }}/release/liblibresl.so dist/ffi/lib/libresl.so
82-
cp target/${{ matrix.target }}/release/liblibresl.a dist/ffi/lib/libresl.a || true
83-
84-
- name: Copy FFI library files (Windows)
85-
if: contains(matrix.target, 'windows')
86-
shell: bash
87-
run: |
88-
cp target/${{ matrix.target }}/release/libresl.dll dist/ffi/lib/ || true
89-
cp target/${{ matrix.target }}/release/libresl.dll.lib dist/ffi/lib/libresl.lib || true
90-
cp target/${{ matrix.target }}/release/libresl.dll.exp dist/ffi/lib/ || true
91-
92-
- name: Copy FFI library files (macOS)
93-
if: contains(matrix.target, 'apple')
94-
run: |
95-
cp target/${{ matrix.target }}/release/liblibresl.dylib dist/ffi/lib/libresl.dylib
96-
cp target/${{ matrix.target }}/release/liblibresl.a dist/ffi/lib/libresl.a || true
97-
98-
- name: Copy headers
99-
run: |
100-
cp include/resl.h dist/ffi/include/
101-
102-
- name: Create FFI archive
103-
shell: bash
104-
run: |
105-
cd dist/ffi
106-
if [[ "${{ matrix.target }}" == *"windows"* ]]; then
107-
zip -r ../../libresl-${{ needs.release-please.outputs.tag_name }}-${{ matrix.target }}.zip .
108-
else
109-
tar -czf ../../libresl-${{ needs.release-please.outputs.tag_name }}-${{ matrix.target }}.tar.gz .
110-
fi
111-
112-
- name: Upload FFI archive
113-
uses: softprops/action-gh-release@v2
114-
with:
115-
tag_name: ${{ needs.release-please.outputs.tag_name }}
116-
files: |
117-
libresl-${{ needs.release-please.outputs.tag_name }}-${{ matrix.target }}.*
118-
env:
119-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
120-
121-
publish-crates:
122-
name: Publish to crates.io
123-
needs: [release-please, upload-assets]
124-
if: ${{ needs.release-please.outputs.release_created }}
125-
runs-on: ubuntu-latest
126-
steps:
127-
- name: Checkout code
128-
uses: actions/checkout@v4
129-
130-
- name: Install Rust toolchain
131-
uses: actions-rust-lang/setup-rust-toolchain@v1
132-
with:
133-
toolchain: stable
134-
135-
- name: Publish resl to crates.io
136-
run: cargo publish --package resl --no-verify || echo "resl already published or failed to publish"
137-
env:
138-
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
139-
140-
- name: Wait before publishing resl-cli
141-
run: sleep 60
142-
143-
- name: Publish resl-cli to crates.io
144-
run: cargo publish --package resl-cli --no-verify || echo "resl-cli already published or failed to publish"
145-
env:
146-
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
147-
148-
publish-docs:
149-
name: Trigger documentation publish
150-
needs: [release-please, upload-assets, publish-crates]
151-
if: ${{ needs.release-please.outputs.release_created }}
152-
runs-on: ubuntu-latest
153-
steps:
154-
- run: gh workflow run publish-docs.yml
155-
env:
156-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1+
name: Release
2+
3+
permissions:
4+
contents: write
5+
pull-requests: write
6+
7+
on:
8+
push:
9+
branches:
10+
- main
11+
12+
env:
13+
CARGO_TERM_COLOR: always
14+
15+
jobs:
16+
release-please:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
release_created: ${{ steps.release.outputs.releases_created }}
20+
tag_name: ${{ steps.release.outputs.resl--tag_name }}
21+
steps:
22+
- name: Run release-please
23+
id: release
24+
uses: googleapis/release-please-action@v4
25+
with:
26+
token: ${{ secrets.RELEASE_PLEASE_PAT }}
27+
28+
release-assets:
29+
name: Upload assets
30+
needs: release-please
31+
if: ${{ needs.release-please.outputs.release_created }}
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
include:
36+
- target: x86_64-unknown-linux-gnu
37+
os: ubuntu-latest
38+
- target: x86_64-pc-windows-msvc
39+
os: windows-latest
40+
- target: aarch64-pc-windows-msvc
41+
os: windows-latest
42+
- target: x86_64-apple-darwin
43+
os: macos-latest
44+
- target: aarch64-apple-darwin
45+
os: macos-latest
46+
47+
runs-on: ${{ matrix.os }}
48+
env:
49+
TAG_NAME: ${{ needs.release-please.outputs.tag_name }}
50+
TARGET: ${{ matrix.target }}
51+
FFI_DIR: dist/ffi
52+
53+
steps:
54+
- name: Checkout code
55+
uses: actions/checkout@v4
56+
57+
- name: Install Rust toolchain
58+
uses: actions-rust-lang/setup-rust-toolchain@v1
59+
with:
60+
toolchain: stable
61+
target: ${{ matrix.target }}
62+
63+
- name: Build CLI binary
64+
run: cargo build --release --package resl-cli --target $TARGET
65+
66+
- name: Copy CLI binary (Linux/macOS)
67+
if: contains(env.TARGET, 'windows') == false
68+
shell: bash
69+
run: |
70+
mkdir -p dist/cli
71+
cp target/$TARGET/release/resl dist/cli/resl-${TAG_NAME}-${TARGET}
72+
73+
- name: Copy CLI binary (Windows)
74+
if: contains(env.TARGET, 'windows')
75+
shell: pwsh
76+
run: |
77+
New-Item -ItemType Directory -Force -Path dist\cli | Out-Null
78+
Copy-Item "target\$env:TARGET\release\resl.exe" "dist\cli\resl-$env:TAG_NAME-$env:TARGET.exe" -Force
79+
80+
- name: Build FFI library
81+
run: cargo build --release --package resl-ffi --target $TARGET
82+
83+
- name: Create FFI package structure (Linux/macOS)
84+
if: contains(env.TARGET, 'windows') == false
85+
shell: bash
86+
run: |
87+
mkdir -p $FFI_DIR/lib $FFI_DIR/include
88+
cp include/resl.h $FFI_DIR/include/
89+
90+
- name: Create FFI package structure (Windows)
91+
if: contains(env.TARGET, 'windows')
92+
shell: pwsh
93+
run: |
94+
New-Item -ItemType Directory -Force -Path "$env:FFI_DIR\lib" | Out-Null
95+
New-Item -ItemType Directory -Force -Path "$env:FFI_DIR\include" | Out-Null
96+
Copy-Item "include\resl.h" "$env:FFI_DIR\include\" -Force
97+
98+
- name: Copy FFI library (Linux)
99+
if: contains(env.TARGET, 'linux')
100+
shell: bash
101+
run: |
102+
cp target/$TARGET/release/liblibresl.so $FFI_DIR/lib/libresl.so || true
103+
cp target/$TARGET/release/liblibresl.a $FFI_DIR/lib/libresl.a || true
104+
105+
- name: Copy FFI library (Windows)
106+
if: contains(env.TARGET, 'windows')
107+
shell: pwsh
108+
run: |
109+
Copy-Item "target\$env:TARGET\release\libresl.dll" "$env:FFI_DIR\lib\" -Force -ErrorAction SilentlyContinue
110+
Copy-Item "target\$env:TARGET\release\libresl.lib" "$env:FFI_DIR\lib\" -Force -ErrorAction SilentlyContinue
111+
Copy-Item "target\$env:TARGET\release\libresl.exp" "$env:FFI_DIR\lib\" -Force -ErrorAction SilentlyContinue
112+
113+
- name: Copy FFI library (macOS)
114+
if: contains(env.TARGET, 'apple')
115+
shell: bash
116+
run: |
117+
cp target/$TARGET/release/liblibresl.dylib $FFI_DIR/lib/libresl.dylib || true
118+
cp target/$TARGET/release/liblibresl.a $FFI_DIR/lib/libresl.a || true
119+
120+
- name: Create FFI library archive (Linux/macOS)
121+
if: contains(env.TARGET, 'windows') == false
122+
shell: bash
123+
run: |
124+
tar -czf $FFI_DIR/libresl-${TAG_NAME}-${TARGET}.tar.gz -C $FFI_DIR .
125+
126+
- name: Create FFI library archive (Windows)
127+
if: contains(env.TARGET, 'windows')
128+
shell: pwsh
129+
run: |
130+
Compress-Archive -Path "$env:FFI_DIR\*" -DestinationPath "$env:FFI_DIR\libresl-$env:TAG_NAME-$env:TARGET.zip" -Force
131+
132+
- name: Upload release assets
133+
uses: softprops/action-gh-release@v2
134+
with:
135+
tag_name: ${{ env.TAG_NAME }}
136+
files: |
137+
dist/cli/resl-${{ env.TAG_NAME }}-${{ env.TARGET }}*
138+
dist/ffi/libresl-${{ env.TAG_NAME }}-${{ env.TARGET }}*
139+
env:
140+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
141+
142+
publish-crates:
143+
name: Publish Crates
144+
needs: [release-please, release-assets]
145+
if: ${{ needs.release-please.outputs.release_created }}
146+
runs-on: ubuntu-latest
147+
steps:
148+
- name: Checkout code
149+
uses: actions/checkout@v4
150+
151+
- name: Install Rust toolchain
152+
uses: actions-rust-lang/setup-rust-toolchain@v1
153+
with:
154+
toolchain: stable
155+
156+
- name: Publish resl to crates.io
157+
run: cargo publish --package resl --no-verify || echo "resl already published or failed to publish"
158+
env:
159+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
160+
161+
- name: Wait before publishing resl-cli
162+
run: sleep 60
163+
164+
- name: Publish resl-cli to crates.io
165+
run: cargo publish --package resl-cli --no-verify || echo "resl-cli already published or failed to publish"
166+
env:
167+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
168+
169+
publish-docs:
170+
name: Publish Documentation
171+
needs: [release-please, release-assets, publish-crates]
172+
if: ${{ needs.release-please.outputs.release_created }}
173+
runs-on: ubuntu-latest
174+
steps:
175+
- run: gh workflow run publish-docs.yml
176+
env:
177+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

release-please-config.json

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
{
22
"release-type": "rust",
3+
"include-v-in-tag": true,
4+
"include-component-in-tag": false,
35
"packages": {
4-
"resl": {},
5-
"resl-cli": {},
6-
"resl-ffi": {}
6+
"resl": {
7+
"component": "resl"
8+
},
9+
"resl-cli": {
10+
"component": "resl"
11+
},
12+
"resl-ffi": {
13+
"component": "resl"
14+
}
715
},
816
"plugins": [
9-
"cargo-workspace"
17+
{
18+
"type": "cargo-workspace",
19+
"merge": true
20+
}
1021
],
11-
"include-v-in-tag": true,
12-
"include-component-in-tag": true,
1322
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
14-
}
23+
}

0 commit comments

Comments
 (0)