Skip to content

Commit 4df0e1a

Browse files
committed
ci: format and move repeat RUST_ settings to env block
1 parent e204baa commit 4df0e1a

File tree

2 files changed

+276
-367
lines changed

2 files changed

+276
-367
lines changed

.github/workflows/cd.yml

Lines changed: 129 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -1,166 +1,134 @@
11
name: Continuous Deployment
2-
32
on:
4-
push:
5-
tags:
6-
- "v*.*.*"
7-
3+
push:
4+
tags:
5+
- "v*.*.*"
6+
env:
7+
RUST_TOOLCHAIN: nightly
8+
RUST_PROFILE: minimal
9+
RUST_TOOLCHAIN_OVERRIDE: true
810
jobs:
9-
check-version:
10-
runs-on: ubuntu-latest
11-
steps:
12-
- name: Checkout code
13-
uses: actions/checkout@v2
14-
- name: Check version
15-
id: check_version
16-
run: |
17-
VERSION=v$(grep '^version =' Cargo.toml | cut -d '"' -f 2 | head -n 1)
18-
GIT_TAG_VERSION=${{ github.ref }}
19-
GIT_TAG_VERSION=${GIT_TAG_VERSION#refs/tags/}
20-
if [[ "$VERSION" != "$GIT_TAG_VERSION" ]]; then
21-
echo "Version in Cargo.toml ($VERSION) does not match pushed tag ($GIT_TAG_VERSION)"
22-
exit 1
23-
fi
24-
25-
build:
26-
needs: [check-version]
27-
strategy:
28-
matrix:
29-
os:
30-
- { NAME: linux, OS: ubuntu-latest, ARCH: x86_64, PATH: target/optimized/bob, TARGET: "" }
31-
- { NAME: linux, OS: ubuntu-24.04-arm, ARCH: arm, PATH: target/optimized/bob, TARGET: "" }
32-
- { NAME: macos, OS: macos-13, ARCH: x86_64, PATH: target/optimized/bob, TARGET: "" }
33-
- { NAME: windows, OS: windows-latest, ARCH: x86_64, PATH: build, TARGET: "" }
34-
- { NAME: macos, OS: macos-latest, ARCH: arm, PATH: target/optimized/bob, TARGET: "" }
35-
tls:
36-
- { NAME: Rustls, SUFFIX: "", ARGS: "" }
37-
- { NAME: OpenSSL, SUFFIX: "-openssl", ARGS: "--no-default-features --features native-tls" }
38-
runs-on: ${{matrix.os.OS}}
39-
steps:
40-
- uses: actions/checkout@v4
41-
- name: Install Rust
42-
uses: actions-rs/toolchain@v1
43-
with:
44-
toolchain: stable
45-
profile: minimal
46-
override: true
47-
- name: Install OpenSSL libraries
48-
run: sudo apt update && sudo apt install libssl-dev
49-
if: matrix.os.OS == 'ubuntu-latest' && matrix.tls.NAME == 'OpenSSL'
50-
- uses: Swatinem/rust-cache@v1
51-
- name: Build Bob
52-
uses: actions-rs/cargo@v1
53-
with:
54-
command: build
55-
args: --locked --profile optimized ${{ matrix.tls.ARGS }}
56-
- name: Install AppImage tools
57-
if: matrix.os.NAME == 'linux' && matrix.tls.NAME == 'Rustls'
58-
run: |
59-
sudo apt update && sudo apt install -y libfuse2 # Needed by AppImage/linuxdeploy
60-
61-
# Determine the correct architecture for linuxdeploy download
62-
DOWNLOAD_ARCH=${{ matrix.os.ARCH }}
63-
if [[ "${{ matrix.os.ARCH }}" == "arm" ]]; then
64-
DOWNLOAD_ARCH="aarch64"
65-
fi
66-
67-
echo "Downloading linuxdeploy tools for architecture: $DOWNLOAD_ARCH"
68-
wget -c "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-$DOWNLOAD_ARCH.AppImage" -O linuxdeploy
69-
wget -c "https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/continuous/linuxdeploy-plugin-appimage-$DOWNLOAD_ARCH.AppImage" -O linuxdeploy-plugin-appimage
70-
chmod +x linuxdeploy linuxdeploy-plugin-appimage
71-
72-
- name: Prepare AppDir
73-
if: matrix.os.NAME == 'linux' && matrix.tls.NAME == 'Rustls'
74-
run: |
75-
mkdir -p AppDir/usr/bin AppDir/usr/share/icons/hicolor/256x256/apps AppDir/usr/share/applications
76-
cp target/optimized/bob AppDir/usr/bin/
77-
cp resources/bob-icon.png AppDir/usr/share/icons/hicolor/256x256/apps/bob.png
78-
cat <<EOF > AppDir/bob.desktop
79-
[Desktop Entry]
80-
Name=Bob Neovim Manager
81-
Exec=bob
82-
Icon=bob
83-
Type=Application
84-
Categories=Utility;Development;
85-
Comment=A cross-platform Neovim version manager
86-
EOF
87-
cp AppDir/bob.desktop AppDir/usr/share/applications/
88-
89-
# Verify the file exists right before linuxdeploy
90-
ls -l AppDir/usr/bin/bob
91-
92-
export UPD_INFO="gh-releases-zsync|Matsuuu|bob|latest|bob-${{ matrix.os.ARCH }}.AppImage.zsync"
93-
export OUTPUT="bob-${{ matrix.os.ARCH }}${{ matrix.tls.SUFFIX }}.AppImage"
94-
95-
# Change --executable path to be relative to CWD
96-
./linuxdeploy --appdir AppDir --executable AppDir/usr/bin/bob --desktop-file AppDir/bob.desktop --icon-file AppDir/usr/share/icons/hicolor/256x256/apps/bob.png --output appimage
97-
98-
99-
- name: Setup Bob build directory
100-
run: |
101-
mkdir build
102-
copy .\\bin\\vcruntime140.dll .\\build
103-
copy .\\target\\optimized\\bob.exe .\\build
104-
if: matrix.os.OS == 'windows-latest'
105-
- name: Upload Bob binary
106-
uses: actions/upload-artifact@v4
107-
with:
108-
name: "bob-${{ matrix.os.NAME }}-${{ matrix.os.ARCH }}${{ matrix.tls.SUFFIX }}"
109-
path: ${{ matrix.os.PATH }}
110-
if-no-files-found: error
111-
- name: Upload Bob AppImage
112-
if: matrix.os.NAME == 'linux' && matrix.tls.NAME == 'Rustls'
113-
uses: actions/upload-artifact@v4
114-
with:
115-
name: "bob-${{ matrix.os.NAME }}-${{ matrix.os.ARCH }}${{ matrix.tls.SUFFIX }}-appimage"
116-
path: "bob-${{ matrix.os.ARCH }}${{ matrix.tls.SUFFIX }}.AppImage*"
117-
if-no-files-found: error
118-
retention-days: 7
11+
check-version:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v2
16+
- name: Check version
17+
id: check_version
18+
run: "VERSION=v$(grep '^version =' Cargo.toml | cut -d '\"' -f 2 | head -n 1)\nGIT_TAG_VERSION=${{ github.ref }} \nGIT_TAG_VERSION=${GIT_TAG_VERSION#refs/tags/}\nif [[ \"$VERSION\" != \"$GIT_TAG_VERSION\" ]]; then\n echo \"Version in Cargo.toml ($VERSION) does not match pushed tag ($GIT_TAG_VERSION)\"\n exit 1\nfi\n"
19+
build:
20+
needs: [check-version]
21+
strategy:
22+
matrix:
23+
os:
24+
- {NAME: linux, OS: ubuntu-latest, ARCH: x86_64, PATH: target/optimized/bob, TARGET: ""}
25+
- {NAME: linux, OS: ubuntu-24.04-arm, ARCH: arm, PATH: target/optimized/bob, TARGET: ""}
26+
- {NAME: macos, OS: macos-13, ARCH: x86_64, PATH: target/optimized/bob, TARGET: ""}
27+
- {NAME: windows, OS: windows-latest, ARCH: x86_64, PATH: build, TARGET: ""}
28+
- {NAME: macos, OS: macos-latest, ARCH: arm, PATH: target/optimized/bob, TARGET: ""}
29+
tls:
30+
- {NAME: Rustls, SUFFIX: "", ARGS: ""}
31+
- {NAME: OpenSSL, SUFFIX: "-openssl", ARGS: "--no-default-features --features native-tls"}
32+
runs-on: ${{matrix.os.OS}}
33+
steps:
34+
- uses: actions/checkout@v4
35+
- name: Install Rust
36+
uses: actions-rs/toolchain@v1
37+
with:
38+
toolchain: ${{ env.RUST_TOOLCHAIN }}
39+
profile: ${{ env.RUST_PROFILE }}
40+
override: ${{ env.RUST_TOOLCHAIN_OVERRIDE }}
41+
- name: Install OpenSSL libraries
42+
run: sudo apt update && sudo apt install libssl-dev
43+
if: matrix.os.OS == 'ubuntu-latest' && matrix.tls.NAME == 'OpenSSL'
44+
- uses: Swatinem/rust-cache@v1
45+
- name: Build Bob
46+
uses: actions-rs/cargo@v1
47+
with:
48+
command: build
49+
args: --locked --profile optimized ${{ matrix.tls.ARGS }}
50+
- name: Install AppImage tools
51+
if: matrix.os.NAME == 'linux' && matrix.tls.NAME == 'Rustls'
52+
run: |
53+
sudo apt update && sudo apt install -y libfuse2 # Needed by AppImage/linuxdeploy
11954
120-
github-release:
121-
needs: [build]
122-
runs-on: ubuntu-latest
123-
steps:
124-
- name: Checkout
125-
uses: actions/checkout@v3
126-
with:
127-
fetch-depth: 0
128-
- name: Download artifacts
129-
uses: actions/download-artifact@v4
130-
with:
131-
path: artifacts
132-
- name: Prepare Release Assets (Zip binaries, keep AppImages separate)
133-
run: |
134-
cd artifacts
135-
# Zip directories (binaries)
136-
find . -mindepth 1 -maxdepth 1 -type d -print0 | while IFS= read -r -d $'\0' dir; do
137-
base=$(basename "$dir")
138-
zip -r "${base}.zip" "$dir"
139-
rm -r "$dir" # Remove original directory after zipping
140-
done
141-
# Move AppImages and zsync files out of subdirectories if they exist
142-
find . -mindepth 2 -name '*.AppImage*' -exec mv {} . \;
143-
# Clean up any remaining empty directories from AppImage artifacts
144-
find . -mindepth 1 -maxdepth 1 -type d -empty -delete
145-
echo "Prepared assets:"
146-
ls -l
147-
- name: Release
148-
uses: softprops/action-gh-release@v1
149-
if: startsWith(github.ref, 'refs/tags/')
150-
with:
151-
generate_release_notes: true
152-
files: |
153-
./artifacts/*
55+
# Determine the correct architecture for linuxdeploy download
56+
DOWNLOAD_ARCH=${{ matrix.os.ARCH }}
57+
if [[ "${{ matrix.os.ARCH }}" == "arm" ]]; then
58+
DOWNLOAD_ARCH="aarch64"
59+
fi
15460
155-
publish-cargo:
156-
needs: github-release
157-
runs-on: ubuntu-latest
158-
steps:
159-
- uses: actions/checkout@v3
160-
- uses: actions-rs/toolchain@v1
161-
with:
162-
toolchain: stable
163-
override: true
164-
- uses: katyo/publish-crates@v2
165-
with:
166-
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
61+
echo "Downloading linuxdeploy tools for architecture: $DOWNLOAD_ARCH"
62+
wget -c "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-$DOWNLOAD_ARCH.AppImage" -O linuxdeploy
63+
wget -c "https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/continuous/linuxdeploy-plugin-appimage-$DOWNLOAD_ARCH.AppImage" -O linuxdeploy-plugin-appimage
64+
chmod +x linuxdeploy linuxdeploy-plugin-appimage
65+
- name: Prepare AppDir
66+
if: matrix.os.NAME == 'linux' && matrix.tls.NAME == 'Rustls'
67+
run: "mkdir -p AppDir/usr/bin AppDir/usr/share/icons/hicolor/256x256/apps AppDir/usr/share/applications\ncp target/optimized/bob AppDir/usr/bin/\ncp resources/bob-icon.png AppDir/usr/share/icons/hicolor/256x256/apps/bob.png\ncat <<EOF > AppDir/bob.desktop\n[Desktop Entry]\nName=Bob Neovim Manager\nExec=bob\nIcon=bob\nType=Application\nCategories=Utility;Development;\nComment=A cross-platform Neovim version manager\nEOF\ncp AppDir/bob.desktop AppDir/usr/share/applications/\n\n# Verify the file exists right before linuxdeploy\nls -l AppDir/usr/bin/bob \n\nexport UPD_INFO=\"gh-releases-zsync|Matsuuu|bob|latest|bob-${{ matrix.os.ARCH }}.AppImage.zsync\"\nexport OUTPUT=\"bob-${{ matrix.os.ARCH }}${{ matrix.tls.SUFFIX }}.AppImage\"\n\n# Change --executable path to be relative to CWD\n./linuxdeploy --appdir AppDir --executable AppDir/usr/bin/bob --desktop-file AppDir/bob.desktop --icon-file AppDir/usr/share/icons/hicolor/256x256/apps/bob.png --output appimage\n"
68+
- name: Setup Bob build directory
69+
run: |
70+
mkdir build
71+
copy .\\bin\\vcruntime140.dll .\\build
72+
copy .\\target\\optimized\\bob.exe .\\build
73+
if: matrix.os.OS == 'windows-latest'
74+
- name: Upload Bob binary
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: "bob-${{ matrix.os.NAME }}-${{ matrix.os.ARCH }}${{ matrix.tls.SUFFIX }}"
78+
path: ${{ matrix.os.PATH }}
79+
if-no-files-found: error
80+
- name: Upload Bob AppImage
81+
if: matrix.os.NAME == 'linux' && matrix.tls.NAME == 'Rustls'
82+
uses: actions/upload-artifact@v4
83+
with:
84+
name: "bob-${{ matrix.os.NAME }}-${{ matrix.os.ARCH }}${{ matrix.tls.SUFFIX }}-appimage"
85+
path: "bob-${{ matrix.os.ARCH }}${{ matrix.tls.SUFFIX }}.AppImage*"
86+
if-no-files-found: error
87+
retention-days: 7
88+
github-release:
89+
needs: [build]
90+
runs-on: ubuntu-latest
91+
steps:
92+
- name: Checkout
93+
uses: actions/checkout@v3
94+
with:
95+
fetch-depth: 0
96+
- name: Download artifacts
97+
uses: actions/download-artifact@v4
98+
with:
99+
path: artifacts
100+
- name: Prepare Release Assets (Zip binaries, keep AppImages separate)
101+
run: |
102+
cd artifacts
103+
# Zip directories (binaries)
104+
find . -mindepth 1 -maxdepth 1 -type d -print0 | while IFS= read -r -d $'\0' dir; do
105+
base=$(basename "$dir")
106+
zip -r "${base}.zip" "$dir"
107+
rm -r "$dir" # Remove original directory after zipping
108+
done
109+
# Move AppImages and zsync files out of subdirectories if they exist
110+
find . -mindepth 2 -name '*.AppImage*' -exec mv {} . \;
111+
# Clean up any remaining empty directories from AppImage artifacts
112+
find . -mindepth 1 -maxdepth 1 -type d -empty -delete
113+
echo "Prepared assets:"
114+
ls -l
115+
- name: Release
116+
uses: softprops/action-gh-release@v1
117+
if: startsWith(github.ref, 'refs/tags/')
118+
with:
119+
generate_release_notes: true
120+
files: |
121+
./artifacts/*
122+
publish-cargo:
123+
needs: github-release
124+
runs-on: ubuntu-latest
125+
steps:
126+
- uses: actions/checkout@v3
127+
- uses: actions-rs/toolchain@v1
128+
with:
129+
toolchain: ${{ env.RUST_TOOLCHAIN }}
130+
# profile: ${{ env.RUST_PROFILE }}
131+
override: ${{ env.RUST_TOOLCHAIN_OVERRIDE }}
132+
- uses: katyo/publish-crates@v2
133+
with:
134+
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}

0 commit comments

Comments
 (0)