-
Notifications
You must be signed in to change notification settings - Fork 22
182 lines (175 loc) · 4.94 KB
/
ci.yml
File metadata and controls
182 lines (175 loc) · 4.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: floki-ci
on:
push:
tags:
# Full version
- "[0-9]+.[0-9]+.[0-9]+"
# Prerelease version
- "[0-9]+.[0-9]+.[0-9]+-*"
pull_request:
branches:
# Trigger on pull requests into main
- main
types: [ opened, synchronize ]
jobs:
lint:
name: Linting and Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Run cargo clippy to pick up any errors
run: cargo clippy --all-targets -- -Dwarnings
- name: Check code is formatted
run: cargo fmt -- --check
build:
name: Build static binary for publishing
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
os:
- ubuntu-24.04
- macos-latest
rust:
- stable
- beta
experimental: [false]
include:
- os: ubuntu-24.04
rust: nightly
experimental: true
steps:
- uses: actions/checkout@v5
- name: Install rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- name: Install cargo-get
run: cargo install cargo-get
- name: Run tests
run: cargo test --all-features
- run: "./build.sh"
env:
OS_NAME: ${{ matrix.os }}
- name: Archive artifacts
uses: actions/upload-artifact@v4
if: ${{ matrix.rust == 'stable' }}
with:
name: stableartifacts-${{ matrix.os }}
path: |
floki*.zip
floki*.tar.gz
rpm:
name: Build and test RPM using cargo generate-rpm
runs-on: ubuntu-24.04
container:
image: almalinux:9
steps:
- uses: actions/checkout@v5
# Download ubuntu artifact instead of rebuilding in alma.
# This is OK because it's statically linked.
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: stableartifacts-ubuntu24.04
path: .
- name: Build RPM
run: |
tar -xzvf floki*.tar.gz
mkdir target/release
cp floki target/release/floki
cargo generate-rpm -s 'release = "1.el9"'
- name: Install RPM
run: find floki*rpm | xargs dnf install -y floki*.rpm
- name: Test installation
run: floki -V
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: rpm
path: |
target/release/floki*.rpm
publish:
name: Publish release artifact
runs-on: ubuntu-latest
if: github.ref_type == 'tag'
needs:
- build
# Required to publish a release
permissions:
contents: write
steps:
- uses: actions/checkout@v5
- name: Install rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Install cargo-get
run: cargo install cargo-get
- name: Publish to crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.PUBLISH_SECRET }}
# After publishing, create a release
- name: Download ubuntu artifacts
uses: actions/download-artifact@v5
with:
name: stableartifacts-ubuntu-24.04
- name: Download macos artifacts
uses: actions/download-artifact@v5
with:
name: stableartifacts-macos-latest
- name: Download RPM
uses: actions/download-artifact@v5
with:
name: rpm
- name: Generate release.txt
run: "./changelog.sh"
- name: Release
uses: softprops/action-gh-release@v2
with:
body_path: release.txt
files: |
floki*.zip
floki*.tar.gz
floki*.rpm
# # Announce the release
# - run: "./announce.sh"
# env:
# ANNOUNCE_HOOK: ${{ secrets.ANNOUNCE_HOOK }}
publish-dry-run:
name: Dry-run publish for non-release artifact
runs-on: ubuntu-latest
if: github.ref_type != 'tag'
needs:
- build
steps:
- uses: actions/checkout@v5
- name: Install rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Install cargo-get
run: cargo install cargo-get
- name: Dry-run publish on non-tags
run: cargo publish --dry-run
# Test downloading the artifacts
- name: Download ubuntu artifacts
uses: actions/download-artifact@v5
with:
name: stableartifacts-ubuntu-24.04
- name: Download macos artifacts
uses: actions/download-artifact@v5
with:
name: stableartifacts-macos-latest
- name: Download rpm
uses: actions/download-artifact@v5
with:
name: rpm
# Test generating release.txt
- name: Generate release.txt
run: "./changelog.sh"