-
-
Notifications
You must be signed in to change notification settings - Fork 6
152 lines (148 loc) · 5.03 KB
/
_ci.yml
File metadata and controls
152 lines (148 loc) · 5.03 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
name: _ci
on:
workflow_call:
inputs:
release_tag:
description: 'The release tag (e.g. v1.0.0)'
required: false
type: string
default: ''
env:
CARGO_TERM_COLOR: always
jobs:
get-rust-version:
runs-on: ubuntu-latest
outputs:
rust-version: ${{ steps.rust-version.outputs.RUST_VERSION }}
steps:
- uses: actions/checkout@v6
- name: Get rust version from .tool-versions
id: rust-version
run: echo "RUST_VERSION=$(grep '^rust ' .tool-versions | awk '{print $2}')" >> $GITHUB_OUTPUT
deny:
needs: get-rust-version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ needs.get-rust-version.outputs.rust-version }}
- name: Install cargo-deny
uses: taiki-e/install-action@v2
with:
tool: cargo-deny
- name: Check Licenses
run: cargo deny check licenses
machete:
needs: get-rust-version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ needs.get-rust-version.outputs.rust-version }}
- name: Install cargo-machete
uses: taiki-e/install-action@v2
with:
tool: cargo-machete
- name: Check for unused dependencies
run: cargo machete
build:
needs: get-rust-version
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
artifact_name: gitopolis-linux-x86_64
binary_name: gitopolis
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: gitopolis-windows-x86_64
binary_name: gitopolis.exe
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: gitopolis-macos-x86_64
binary_name: gitopolis
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: gitopolis-macos-aarch64
binary_name: gitopolis
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ needs.get-rust-version.outputs.rust-version }}
targets: ${{ matrix.target }}
- name: Cache Cargo registry
uses: actions/cache@v5
with:
path: ~/.cargo/registry/index
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache Cargo dependencies
uses: actions/cache@v5
with:
path: ~/.cargo/registry/cache
key: ${{ runner.os }}-cargo-deps-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-deps-
- name: Cache build artifacts
uses: actions/cache@v5
with:
path: target
key: ${{ runner.os }}-${{ matrix.target }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('**/*.rs') }}
restore-keys: |
${{ runner.os }}-${{ matrix.target }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}-
${{ runner.os }}-${{ matrix.target }}-cargo-build-
- name: Debug - Test shell commands availability
shell: bash
run: |
echo "=== Testing shell commands used in gitopolis tests ==="
echo "hello" | sort
- name: Install musl tools
if: matrix.target == 'x86_64-unknown-linux-musl'
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
- name: Update Version (Linux/Windows)
if: inputs.release_tag != '' && matrix.os != 'macos-latest'
shell: bash
run: |
VERSION="${{ inputs.release_tag }}"
# Strip the 'v' prefix if present
VERSION="${VERSION#v}"
sed -i "s/0\\.0\\.0-git/$VERSION/" Cargo.toml
sed -i "s/0\\.0\\.0-git/$VERSION/" Cargo.lock
- name: Update Version (macOS)
if: inputs.release_tag != '' && matrix.os == 'macos-latest'
shell: bash
run: |
VERSION="${{ inputs.release_tag }}"
# Strip the 'v' prefix if present
VERSION="${VERSION#v}"
sed -i '' "s/0\\.0\\.0-git/$VERSION/" Cargo.toml
sed -i '' "s/0\\.0\\.0-git/$VERSION/" Cargo.lock
- name: Set macOS deployment target
if: runner.os == 'macOS'
run: echo "MACOSX_DEPLOYMENT_TARGET=10.7" >> $GITHUB_ENV
- name: Build
run: cargo build --target ${{ matrix.target }} --release
- name: Test
run: cargo test --verbose --release --no-fail-fast
- name: Package Binary
shell: bash
run: |
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
7z a ${{ matrix.artifact_name }}.zip "target/${{ matrix.target }}/release/${{ matrix.binary_name }}"
else
tar -czvf ${{ matrix.artifact_name }}.tar.gz -C "target/${{ matrix.target }}/release" "${{ matrix.binary_name }}"
fi
- name: Upload Build Artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact_name }}
path: ${{ matrix.artifact_name }}.*
retention-days: 1