-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (131 loc) · 4.32 KB
/
build.yaml
File metadata and controls
152 lines (131 loc) · 4.32 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: Build and Release
on:
push:
branches: [main]
tags:
- "v*"
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
BINARY_NAME: git-task-cli
jobs:
build:
name: Build ${{ matrix.platform }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- platform: linux
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
binary_path: target/release/git-task-cli
asset_name: git-task-cli-linux-amd64
- platform: windows
os: windows-latest
target: x86_64-pc-windows-msvc
binary_path: target/release/git-task-cli.exe
asset_name: git-task-cli-windows-amd64.exe
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: stable
targets: ${{ matrix.target }}
# Install dependencies for Linux build
- name: Install Linux dependencies
if: matrix.platform == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y libssl-dev libgit2-dev pkg-config
# Install dependencies for Windows build
- name: Install Windows dependencies
if: matrix.platform == 'windows'
uses: msys2/setup-msys2@v2
with:
install: mingw-w64-x86_64-libgit2
# Rust caching
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Build
run: cargo build --release
- name: List build directory
run: |
ls -la target/release/
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: ${{ matrix.binary_path }}
if-no-files-found: error
release:
name: Create GitHub Release
needs: build
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Extract tag name
id: get_tag
run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
shell: bash
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Display structure of downloaded files
run: ls -R ./artifacts
shell: bash
- name: Prepare release assets
run: |
mkdir -p release-assets
cp ./artifacts/git-task-cli-linux-amd64/git-task-cli ./release-assets/git-task-cli-linux-amd64
cp ./artifacts/git-task-cli-windows-amd64.exe/git-task-cli.exe ./release-assets/git-task-cli-windows-amd64.exe
chmod +x ./release-assets/git-task-cli-linux-amd64
# Create zip archives
cd release-assets
zip git-task-cli-linux-amd64.zip git-task-cli-linux-amd64
zip git-task-cli-windows-amd64.zip git-task-cli-windows-amd64.exe
shell: bash
- name: Create Release
uses: softprops/action-gh-release@v2
with:
name: Release ${{ steps.get_tag.outputs.TAG }}
files: |
release-assets/git-task-cli-linux-amd64
release-assets/git-task-cli-windows-amd64.exe
release-assets/git-task-cli-linux-amd64.zip
release-assets/git-task-cli-windows-amd64.zip
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
# This job is run for every push to main to publish the latest build artifacts
publish-artifacts:
name: Publish Latest Artifacts
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Display artifacts
run: ls -R ./artifacts
shell: bash
- name: Create build date variable
id: build_date
run: echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
shell: bash
- name: Upload latest build artifacts
uses: actions/upload-artifact@v4
with:
name: git-task-cli-latest-${{ steps.build_date.outputs.DATE }}
path: ./artifacts
retention-days: 7