-
-
Notifications
You must be signed in to change notification settings - Fork 5
157 lines (136 loc) · 4.8 KB
/
Copy pathCI.yml
File metadata and controls
157 lines (136 loc) · 4.8 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
name: Build, Test, and Release
permissions:
contents: write # Required for creating releases and uploading assets
on:
push:
paths-ignore:
- 'plugin/**'
branches: [ "main" ]
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*' # Trigger on version tags like v0.1.0
pull_request:
paths-ignore:
- 'plugin/**'
branches: [ "main" ]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
# Job 1: Runs on every push/PR
build_and_test:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check cargo formatting
run: cargo fmt -- --check
- name: Build
run: cargo build
- name: Run tests
run: cargo test
- name: Install choreo
run: cargo install choreo
- name: Install tbdflow on PATH
run: cargo install --path .
- name: Configure git for BDD tests
run: |
git config --global user.email "ci@tbdflow.dev"
git config --global user.name "tbdflow CI"
git config --global init.defaultBranch main
- name: Run choreo BDD tests
run: |
choreo run --file tests/tbdflow_branch.chor
choreo run --file tests/tbdflow_commit_types.chor
choreo run --file tests/tbdflow_commit.chor
choreo run --file tests/tbdflow_complete.chor
choreo run --file tests/tbdflow_sync_status.chor
choreo run --file tests/tbdflow_undo.chor
choreo run --file tests/tbdflow_radar.chor
# Job 2: Creates the release on GitHub. Only runs on new tags.
create_release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: build_and_test
if: startsWith(github.ref, 'refs/tags/v')
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
draft: false
prerelease: false
# Job 3: Builds binaries for multiple platforms and uploads them. Only runs on new tags.
build_and_upload_assets:
name: Build & Upload Release Assets
needs: create_release
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install aarch64 linker (for cross-compiling on Ubuntu)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Build binary
env:
# Set linker for aarch64 cross-compile
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
run: cargo build --verbose --release --target ${{ matrix.target }}
- name: Package binary for release
shell: bash
run: |
# The binary will be in the release directory
cd target/${{ matrix.target }}/release
# Rename the binary to include the target triple
if [ "${{ matrix.os }}" = "windows-latest" ]; then
mv tbdflow.exe tbdflow-${{ matrix.target }}.exe
echo "ASSET_NAME=tbdflow-${{ matrix.target }}.exe" >> $GITHUB_ENV
else
mv tbdflow tbdflow-${{ matrix.target }}
echo "ASSET_NAME=tbdflow-${{ matrix.target }}" >> $GITHUB_ENV
fi
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./target/${{ matrix.target }}/release/${{ env.ASSET_NAME }}
asset_name: ${{ env.ASSET_NAME }}
asset_content_type: application/octet-stream
# Job 4: Publishes to crates.io. Only runs on new tags.
publish_to_crates:
name: Publish to crates.io
needs: build_and_test
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Publish to crates.io
run: cargo publish --allow-dirty --token ${{ secrets.CRATES_TOKEN }}