-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (102 loc) · 3.5 KB
/
Copy pathci.yml
File metadata and controls
124 lines (102 loc) · 3.5 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
---
name: CI
on:
pull_request:
push:
branches:
- main
tags:
- "v*"
# contents: read covers all jobs. A future release-publishing job will need
# contents: write — set it at the job level there rather than widening here.
permissions:
contents: read
env:
# Derived from the tag (v1.2.3 → 1.2.3) on tag pushes; falls back to
# 0.0.0-dev for branch builds so nfpm always has a valid version string.
VERSION: ${{ startsWith(github.ref, 'refs/tags/v') && github.ref_name || '0.0.0-dev' }}
# Bump this when a new nfpm release is available.
NFPM_VERSION: "2.46.3"
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v5
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml', '**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Check formatting
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run tests
run: cargo test --all
build:
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v6
- name: Install Rust stable + musl target
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-musl
- name: Install musl tools
run: sudo apt-get install -y musl-tools
- name: Build static release binary
run: cargo build --release --target x86_64-unknown-linux-musl
- name: Upload binary artifact
uses: actions/upload-artifact@v7
with:
name: fix-perms-x86_64-musl
path: target/x86_64-unknown-linux-musl/release/fix-perms
if-no-files-found: error
package:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v6
- name: Install Rust stable
run: rustup toolchain install stable
- name: Download binary artifact
uses: actions/download-artifact@v7
with:
name: fix-perms-x86_64-musl
path: target/x86_64-unknown-linux-musl/release/
- name: Restore binary permissions
run: chmod +x target/x86_64-unknown-linux-musl/release/fix-perms
- name: Derive package version
id: version
run: |
# Strip the leading 'v' from tag names (v1.2.3 → 1.2.3).
# Both dpkg and rpm reject version strings that start with 'v'.
ref="${GITHUB_REF_NAME}"
echo "value=${ref#v}" >> "$GITHUB_OUTPUT"
- name: Install nfpm
run: |
curl -fsSL \
"https://github.com/goreleaser/nfpm/releases/download/v${NFPM_VERSION}/nfpm_${NFPM_VERSION}_amd64.deb" \
-o /tmp/nfpm.deb
sudo dpkg -i /tmp/nfpm.deb
rm /tmp/nfpm.deb
- name: Build packages
run: cargo xtask build
env:
VERSION: ${{ steps.version.outputs.value }}
- name: Upload packages
uses: actions/upload-artifact@v7
with:
name: ignity-extensions-packages
path: dist/
if-no-files-found: error