-
-
Notifications
You must be signed in to change notification settings - Fork 0
219 lines (193 loc) · 8.44 KB
/
publish-to-repositories.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
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
name: Publish to Repositories
on:
push:
branches: ["main"]
workflow_dispatch:
inputs:
publish:
description: 'Run publish job'
required: true
default: 'no'
type: choice
options:
- 'no'
- 'yes'
aur:
description: 'Run AUR publish job'
required: true
default: 'no'
type: choice
options:
- 'no'
- 'yes'
jobs:
build:
if: ${{ endsWith(github.event.head_commit.message, '--publish') || inputs.publish == 'yes' }}
runs-on: ubuntu-latest
environment: Linux
env:
CARGO_TERM_COLOR: always
WORKSPACE: ${{ github.workspace }}
RUST_BACKTRACE: full
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
steps:
# Setup Build Environment
- name: 🎉 The job was automatically triggered by a ${{ github.event_name }} event.
run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- name: 🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!
run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- name: 🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}.
run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v4
with:
lfs: true
submodules: recursive
- name: 💡 The ${{ github.repository }} repository has been cloned to the runner.
run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
# Install Dependencies
- name: Install and Cache APT Packages
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: gcc g++ makepkg # gcc-x86-64-linux-gnu g++-x86-64-linux-gnu
version: 1.0
execute_install_scripts: true
# Install Rust
- name: Make Tools Directory
run: mkdir -p ${{ github.workspace }}/tools
- name: Download Rust Installer
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > ${{ github.workspace }}/tools/rust.sh
- name: Make Rust Installer Executable
run: chmod +x ${{ github.workspace }}/tools/rust.sh
- name: Install Rust
run: ${{ github.workspace }}/tools/rust.sh -y
- name: Load Cargo Environment
run: source "$HOME/.cargo/env"
# Install Rust Stable Toolchains
- name: Set Rust To The Stable Toolchains
run: $HOME/.cargo/bin/rustup default stable
# Setup Rust Build Caching
- uses: Swatinem/rust-cache@v2
with:
shared-key: "crates-io-linux-rust-gnu-x86_64"
# Add Build Targets
- name: Add x86_64 GNU Build Target
run: $HOME/.cargo/bin/rustup target add x86_64-unknown-linux-gnu
# Install Git Pre-Commit Hooks to Enforce Hooks
- name: Install Git Pre-Commit Hooks to Enforce Hooks
run: pip install pre-commit
# Check Pre-Commit Version
- name: Check Pre-Commit Version
run: pre-commit --version
# Install Pre-Commit Hooks
- name: Install Pre-Commit Hooks
run: pre-commit install
# Check Files with Pre-Commit Hooks
- name: Check Files with Pre-Commit Hooks
run: pre-commit run --all-files
# Publish to Crates.io
- name: Publish to catgirl-engine-macros to Crates.io
run: cargo publish -p catgirl-engine-macros --no-verify
# Publish to Crates.io
- name: Publish to catgirl-engine-utils to Crates.io
run: cargo publish -p catgirl-engine-utils --no-verify
# Publish to Crates.io
- name: Publish to catgirl-engine-client to Crates.io
run: cargo publish -p catgirl-engine-client --no-verify
# Publish to Crates.io
- name: Publish to catgirl-engine-server to Crates.io
run: cargo publish -p catgirl-engine-server --no-verify
# Publish to Crates.io
- name: Publish to catgirl-engine to Crates.io
run: cargo publish -p catgirl-engine --no-verify --allow-dirty
aur:
if: ${{ success() || inputs.aur == 'yes' }}
needs: [Build]
runs-on: ubuntu-latest
environment: Linux
steps:
# Check out repository code
- name: Check out repository code
uses: actions/checkout@v4
with:
lfs: true
submodules: recursive
# Write SSH Private Key
- name: Write SSH Private Key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.AUR_SSH }}" > ~/.ssh/aur
echo -e "Host aur.archlinux.org\n\tHostname aur.archlinux.org\n\tUser git\n\tIdentityFile ~/.ssh/aur\n\tIdentitiesOnly yes" > ~/.ssh/config
echo "${{ vars.AUR_KNOWN_HOSTS }}" > ~/.ssh/known_hosts
chmod 0600 ~/.ssh/aur
chmod 0600 ~/.ssh/config
chmod 0600 ~/.ssh/known_hosts
# Clone AUR Repo
- name: Clone AUR Repo
run: git clone ssh://[email protected]/catgirl-engine.git ${{ github.workspace }}/aur
# Bump PKGBUILD Version
- name: Bump PKGBUILD Version
run: |
export VERSION=`cat ${{ github.workspace }}/Cargo.toml | grep '^version' | head -n1 | cut -d'"' -f2 | tr -d '\n'`
export PKGVER=`echo -ne $VERSION | sed "s/-/./"`
export PKGREL=1
# TODO: Consider checking for -alpha and -beta to filter onto other packages
echo "Version: $VERSION - Package Version: $PKGVER - Release: $PKGREL"
sed -i "s/cratever=[0-9.a-zA-Z\-]*/cratever=$VERSION/" ${{ github.workspace }}/aur/PKGBUILD
sed -i "s/pkgver=[0-9.a-zA-Z\-]*/pkgver=$PKGVER/" ${{ github.workspace }}/aur/PKGBUILD
sed -i "s/pkgrel=[0-9]*/pkgrel=$PKGREL/" ${{ github.workspace }}/aur/PKGBUILD
# Generating SRCINFO (Manually)
- name: Generating SRCINFO (Manually)
run: |
export VERSION=`cat ${{ github.workspace }}/Cargo.toml | grep '^version' | head -n1 | cut -d'"' -f2 | tr -d '\n'`
export PKGVER=`echo -ne $VERSION | sed "s/-/./"`
export PKGREL=1
export DOWNLOAD_PATH="catgirl-engine-$VERSION.tar.gz::https://static.crates.io/crates/catgirl-engine/catgirl-engine-$VERSION.crate"
echo "Version: $VERSION - Package Version: $PKGVER - Release: $PKGREL"
echo "Download Path: $DOWNLOAD_PATH"
cd ${{ github.workspace }}/aur
# makepkg --printsrcinfo > ${{ github.workspace }}/aur/.SRCINFO
sed -i "s/pkgver = [0-9.a-zA-Z\-]*/pkgver = $PKGVER/" ${{ github.workspace }}/aur/.SRCINFO
sed -i "s/pkgrel = [0-9]*/pkgrel = $PKGREL/" ${{ github.workspace }}/aur/.SRCINFO
sed -i "s|source = .*|source = $DOWNLOAD_PATH|" ${{ github.workspace }}/aur/.SRCINFO
# Upload Repo As Artifact
- name: Upload Repo As Artifact
uses: actions/upload-artifact@v4
with:
name: CatgirlEngine-AUR-Repo
path: ${{ github.workspace }}/aur/*
include-hidden-files: true
# Setting Git Author Info
- name: Setting Git Author Info
run: |
echo Setting Git Author Info
git config --global user.email "${{ vars.GIT_EMAIL }}"
git config --global user.name "${{ vars.GIT_NAME }}"
# Publish Update to Arch User Repository (AUR)
- name: Publish Update to Arch User Repository (AUR)
run: |
cd ${{ github.workspace }}/aur
git add PKGBUILD .SRCINFO
git commit -m "Updating latest version"
git push
announce:
if: ${{ success() }}
needs: [AUR]
runs-on: ubuntu-latest
environment: Linux
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
steps:
# Check out repository code
- name: Check out repository code
uses: actions/checkout@v4
with:
lfs: true
submodules: recursive
# Publish Announcement to Notification Channel
- name: Publish Announcement to Notification Channel
run: |
export VERSION=`cat ${{ github.workspace }}/Cargo.toml | grep '^version' | head -n1 | cut -d'"' -f2 | tr -d '\n'`
export VERSION_STRING="Catgirl Engine v$VERSION"
export MESSAGE="[$VERSION_STRING has been published...](https://github.com/foxgirl-labs/catgirl-engine/releases/tag/v$VERSION)"
curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data "{\"content\": \"$MESSAGE\"}" $DISCORD_WEBHOOK_URL