Skip to content

Commit aa75da9

Browse files
committed
Separate CI and release workflows
1 parent faefde1 commit aa75da9

File tree

2 files changed

+114
-83
lines changed

2 files changed

+114
-83
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ name: CI
33
on:
44
push:
55
branches: [main]
6+
tags:
7+
- "v*"
68
pull_request:
79
branches: [main]
810

9-
# Required for softprops/action-gh-release to upload release assets
10-
permissions:
11-
contents: write
12-
1311
env:
1412
CARGO_TERM_COLOR: always
1513

@@ -51,82 +49,3 @@ jobs:
5149

5250
- name: Run tests
5351
run: cargo test --verbose
54-
55-
release:
56-
needs: test
57-
runs-on: ${{ matrix.os }}
58-
if: startsWith(github.ref, 'refs/tags/v')
59-
strategy:
60-
matrix:
61-
include:
62-
- os: ubuntu-latest
63-
target: x86_64-unknown-linux-gnu
64-
artifact: peas
65-
- os: macos-latest
66-
target: x86_64-apple-darwin
67-
artifact: peas
68-
- os: macos-latest
69-
target: aarch64-apple-darwin
70-
artifact: peas
71-
- os: windows-latest
72-
target: x86_64-pc-windows-msvc
73-
artifact: peas.exe
74-
75-
steps:
76-
- uses: actions/checkout@v4
77-
78-
- name: Install Rust
79-
uses: dtolnay/rust-toolchain@stable
80-
with:
81-
targets: ${{ matrix.target }}
82-
83-
- name: Cache cargo
84-
uses: actions/cache@v4
85-
with:
86-
path: |
87-
~/.cargo/registry/index/
88-
~/.cargo/registry/cache/
89-
~/.cargo/git/db/
90-
target/
91-
key: ${{ runner.os }}-${{ matrix.target }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
92-
restore-keys: |
93-
${{ runner.os }}-${{ matrix.target }}-cargo-release-
94-
${{ runner.os }}-${{ matrix.target }}-cargo-
95-
96-
- name: Build release
97-
run: cargo build --release --target ${{ matrix.target }} --verbose
98-
99-
- name: Package (Unix)
100-
if: matrix.os != 'windows-latest'
101-
run: |
102-
cd target/${{ matrix.target }}/release
103-
tar czf ../../../peas-${{ matrix.target }}.tar.gz ${{ matrix.artifact }}
104-
cd ../../..
105-
shasum -a 256 peas-${{ matrix.target }}.tar.gz > peas-${{ matrix.target }}.tar.gz.sha256
106-
107-
- name: Package (Windows)
108-
if: matrix.os == 'windows-latest'
109-
shell: bash
110-
run: |
111-
cd target/${{ matrix.target }}/release
112-
7z a ../../../peas-${{ matrix.target }}.zip ${{ matrix.artifact }}
113-
cd ../../..
114-
sha256sum peas-${{ matrix.target }}.zip > peas-${{ matrix.target }}.zip.sha256
115-
116-
- name: Upload artifact
117-
uses: actions/upload-artifact@v4
118-
with:
119-
name: peas-${{ matrix.target }}
120-
path: |
121-
peas-${{ matrix.target }}.*
122-
123-
- name: Release
124-
uses: softprops/action-gh-release@v1
125-
if: startsWith(github.ref, 'refs/tags/v')
126-
with:
127-
files: |
128-
peas-${{ matrix.target }}.*
129-
draft: false
130-
prerelease: false
131-
env:
132-
GITHUB_TOKEN: ${{ secrets.GH_RELEASE_PAT_FOR_PEAS }}

.github/workflows/release.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
checks: read
11+
actions: read
12+
13+
env:
14+
CARGO_TERM_COLOR: always
15+
16+
jobs:
17+
# Wait for CI to pass before building release artifacts
18+
check-ci:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Wait for CI to succeed
22+
uses: lewagon/wait-on-check-action@v1.3.4
23+
with:
24+
ref: ${{ github.ref }}
25+
check-name: "test"
26+
repo-token: ${{ secrets.GITHUB_TOKEN }}
27+
28+
build:
29+
needs: check-ci
30+
runs-on: ${{ matrix.os }}
31+
strategy:
32+
matrix:
33+
include:
34+
- os: ubuntu-latest
35+
target: x86_64-unknown-linux-gnu
36+
artifact: peas
37+
- os: macos-latest
38+
target: x86_64-apple-darwin
39+
artifact: peas
40+
- os: macos-latest
41+
target: aarch64-apple-darwin
42+
artifact: peas
43+
- os: windows-latest
44+
target: x86_64-pc-windows-msvc
45+
artifact: peas.exe
46+
47+
steps:
48+
- uses: actions/checkout@v4
49+
50+
- name: Install Rust
51+
uses: dtolnay/rust-toolchain@stable
52+
with:
53+
targets: ${{ matrix.target }}
54+
55+
- name: Cache cargo
56+
uses: actions/cache@v4
57+
with:
58+
path: |
59+
~/.cargo/registry/index/
60+
~/.cargo/registry/cache/
61+
~/.cargo/git/db/
62+
target/
63+
key: ${{ runner.os }}-${{ matrix.target }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
64+
restore-keys: |
65+
${{ runner.os }}-${{ matrix.target }}-cargo-release-
66+
${{ runner.os }}-${{ matrix.target }}-cargo-
67+
68+
- name: Build release
69+
run: cargo build --release --target ${{ matrix.target }} --verbose
70+
71+
- name: Package (Unix)
72+
if: matrix.os != 'windows-latest'
73+
run: |
74+
cd target/${{ matrix.target }}/release
75+
tar czf ../../../peas-${{ matrix.target }}.tar.gz ${{ matrix.artifact }}
76+
cd ../../..
77+
shasum -a 256 peas-${{ matrix.target }}.tar.gz > peas-${{ matrix.target }}.tar.gz.sha256
78+
79+
- name: Package (Windows)
80+
if: matrix.os == 'windows-latest'
81+
shell: bash
82+
run: |
83+
cd target/${{ matrix.target }}/release
84+
7z a ../../../peas-${{ matrix.target }}.zip ${{ matrix.artifact }}
85+
cd ../../..
86+
sha256sum peas-${{ matrix.target }}.zip > peas-${{ matrix.target }}.zip.sha256
87+
88+
- name: Upload artifact
89+
uses: actions/upload-artifact@v4
90+
with:
91+
name: peas-${{ matrix.target }}
92+
path: |
93+
peas-${{ matrix.target }}.*
94+
95+
release:
96+
needs: build
97+
runs-on: ubuntu-latest
98+
steps:
99+
- name: Download all artifacts
100+
uses: actions/download-artifact@v4
101+
with:
102+
path: artifacts
103+
104+
- name: Create Release
105+
uses: softprops/action-gh-release@v1
106+
with:
107+
files: artifacts/**/*
108+
draft: false
109+
prerelease: false
110+
generate_release_notes: true
111+
env:
112+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)