-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (127 loc) · 3.88 KB
/
Copy pathrelease.yaml
File metadata and controls
134 lines (127 loc) · 3.88 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
name: Release to crates.io and GitHub
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
lint:
name: Lint & Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: clippy, rustfmt
- run: cargo fmt --check
- run: cargo clippy --all-targets --all-features -- -D warnings
test:
name: Run Tests
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- run: cargo test --all
- run: cargo build --release
- name: Upload release binary
uses: actions/upload-artifact@v4
with:
name: gitshift
path: target/release/gitshift
publish-cratesio:
name: Publish to crates.io
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Extract version from Git tag
id: extract_version
run: |
VERSION="${GITHUB_REF#refs/tags/v}"
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Update Cargo.toml version
run: |
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml
- name: Publish to crates.io
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} --allow-dirty
build-all:
name: Build for All Platforms
needs: test
runs-on: ubuntu-latest
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name: linux-amd64
artifact_name: gitshift
asset_name: gitshift-linux-amd64
- target: x86_64-apple-darwin
os: macos-latest
name: darwin-amd64
artifact_name: gitshift
asset_name: gitshift-macos-amd64
- target: aarch64-apple-darwin
os: macos-latest
name: darwin-arm64
artifact_name: gitshift
asset_name: gitshift-macos-arm64
- target: x86_64-pc-windows-msvc
os: windows-latest
name: windows-amd64
artifact_name: gitshift.exe
asset_name: gitshift-windows-amd64.exe
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
target: ${{ matrix.target }}
- uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --release --target ${{ matrix.target }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
github-release:
name: Create GitHub Release
needs: build-all
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: List artifacts
run: ls -R artifacts/
- name: Prepare release files
run: |
mkdir release-assets
cp artifacts/linux-amd64/gitshift release-assets/gitshift-linux-amd64
cp artifacts/darwin-amd64/gitshift release-assets/gitshift-macos-amd64
cp artifacts/darwin-arm64/gitshift release-assets/gitshift-macos-arm64
cp artifacts/windows-amd64/gitshift.exe release-assets/gitshift-windows-amd64.exe
chmod +x release-assets/*
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: release-assets/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}