-
Notifications
You must be signed in to change notification settings - Fork 1
134 lines (115 loc) · 3.55 KB
/
cd.yml
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: CD
on:
push:
branches: [trigger]
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: write
actions: write
packages: write
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
ACTIONS_RUNTIME_TOKEN: dummy
CARGO_TERM_COLOR: always
jobs:
# Version bump and tag creation on main push
#
# On: Push to main
# Do: 1. Bump version using cargo-bump
# 2. Push to tag and changes to main
version-bump:
if: github.ref == 'refs/heads/trigger' && github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- name: Configure git
run: |
git config user.name ${{ github.actor }}
git config user.email ${{ github.actor }}@users.noreply.github.com
- name: Install cargo-bump
run: cargo install cargo-bump
- name: Bump version and create tag
run: |
cargo bump patch --git-tag
git commit -a --amend --no-edit
git push origin HEAD --tags
# Build and upload artifacts when release is published (including pre-releases)
#
# On: Release is published
# Do: 1. Build artifacts for all platforms
# 2. Upload artifacts to release
build-artifacts:
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-latest
target: x86_64-apple-darwin
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: aarch64-apple-darwin
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
steps:
- uses: actions/checkout@v4
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: ${{ matrix.target }}
override: true
- name: Add x86_64-unknown-linux-musl target
if: matrix.target == 'x86_64-unknown-linux-musl'
run: |
rustup target add x86_64-unknown-linux-musl
sudo apt-get update && sudo apt-get install -y musl-tools
- name: Install Dependencies for musl Target
if: matrix.target == 'x86_64-unknown-linux-musl'
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libssl-dev
- name: Build for target
run: |
cargo build \
-Z unstable-options \
--profile dev \
--artifact-dir bin \
--target ${{ matrix.target }}
- name: Zip artifacts
run: zip -r git-ai-${{ matrix.target }}.zip bin/git-*
- name: Upload artifacts
uses: softprops/action-gh-release@v2
with:
files: git-ai-*.zip
tag_name: ${{ github.event.release.tag_name }}
# Publish to crates.io when release is published
#
# On: Release is published
# Do: 1. Publish to crates.io
publish:
needs: build-artifacts
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- name: Publish to crates.io
run: cargo publish --allow-dirty