blob: ef4f58e7378f49cdf91a8c609b92c98eed5dcb26 (
plain) (
blame)
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
158
159
160
161
162
163
164
165
166
167
168
169
|
name: Build and Release
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: linux
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
artifact_name: linux-musl
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: windows
steps:
- uses: actions/checkout@v4
- name: Checkout mingling dependency
uses: actions/checkout@v4
with:
repository: CatilGrass/mingling
path: mingling
ref: main
- name: Setup workspace structure
shell: bash
run: |
mv mingling ..
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Install musl-tools for linux-musl target
if: matrix.target == 'x86_64-unknown-linux-musl'
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
- name: Cache cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Build for target
run: cargo build --release --target ${{ matrix.target }}
env:
CARGO_TARGET_DIR: target
CARGO_NET_GIT_FETCH_WITH_CLI: true
- name: Prepare artifacts and create archives
shell: bash
run: |
mkdir -p artifacts
if [ "${{ matrix.os }}" = "windows-latest" ]; then
# Windows artifacts
mkdir -p cobill-windows
cp target/${{ matrix.target }}/release/cobill.exe cobill-windows/ || true
cp target/${{ matrix.target }}/release/cobill_comp.ps1 cobill-windows/ || true
# Install zip on Windows runner
choco install zip -y
zip -r artifacts/cobill-windows.zip cobill-windows/
else
# Linux artifacts
mkdir -p cobill-${{ matrix.artifact_name }}
cp target/${{ matrix.target }}/release/cobill cobill-${{ matrix.artifact_name }}/ || true
cp target/${{ matrix.target }}/release/cobill_comp.sh cobill-${{ matrix.artifact_name }}/ || true
cp target/${{ matrix.target }}/release/cobill_comp.zsh cobill-${{ matrix.artifact_name }}/ || true
cp target/${{ matrix.target }}/release/cobill_comp.fish cobill-${{ matrix.artifact_name }}/ || true
# Make Linux binaries executable
chmod +x cobill-${{ matrix.artifact_name }}/cobill || true
chmod +x cobill-${{ matrix.artifact_name }}/cobill_comp.sh || true
chmod +x cobill-${{ matrix.artifact_name }}/cobill_comp.zsh || true
chmod +x cobill-${{ matrix.artifact_name }}/cobill_comp.fish || true
tar -czf artifacts/cobill-${{ matrix.artifact_name }}.tar.gz cobill-${{ matrix.artifact_name }}/
fi
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}-archives
path: artifacts/cobill-*
retention-days: 7
release:
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout cobill repository
uses: actions/checkout@v4
with:
path: cobill
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Read version from Cargo.toml
id: version
run: |
if [ -f "cobill/Cargo.toml" ]; then
VERSION=$(grep -m1 '^version =' cobill/Cargo.toml | cut -d'"' -f2)
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
else
echo "VERSION=unknown" >> $GITHUB_OUTPUT
fi
- name: Read CHANGELOG.md
id: changelog
run: |
if [ -f "cobill/CHANGELOG.md" ]; then
# Get current date in YYYY-MM-DD format
RELEASE_DATE=$(date -u '+%Y-%m-%d')
# Read the changelog file from the cobill checkout
CHANGELOG_CONTENT=$(cat cobill/CHANGELOG.md)
# Prepend release date header
echo "Release ($RELEASE_DATE)" > release_body.txt
echo "" >> release_body.txt
echo "$CHANGELOG_CONTENT" >> release_body.txt
# Append commit SHA
echo "" >> release_body.txt
echo "Commit: ${{ github.sha }}" >> release_body.txt
else
# Fallback if CHANGELOG.md doesn't exist
echo "Release ($(date -u '+%Y-%m-%d'))" > release_body.txt
echo "" >> release_body.txt
echo "Automated release from master branch" >> release_body.txt
echo "" >> release_body.txt
echo "Commit: ${{ github.sha }}" >> release_body.txt
fi
- name: Create release
uses: softprops/action-gh-release@v1
with:
files: |
artifacts/linux-archives/cobill-linux.tar.gz
artifacts/linux-musl-archives/cobill-linux-musl.tar.gz
artifacts/windows-archives/cobill-windows.zip
tag_name: v${{ steps.version.outputs.VERSION }}
name: Release v${{ steps.version.outputs.VERSION }}
body_path: release_body.txt
draft: false
prerelease: false
|