Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci/package linux #183

Merged
merged 2 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 40 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@ jobs:
- target: macos
os: macos-latest
make: bash scripts/build-macos.sh
binary_path: target/release/macos/halloy.dmg
artifact_path: |
echo "ARTIFACT_PATH=target/release/macos/halloy.dmg" >> "$GITHUB_ENV"
- target: windows
os: windows-latest
make: bash scripts/build-windows.sh
binary_path: target/release/halloy.exe
artifact_path: |
echo "ARTIFACT_PATH=target/release/halloy.exe" >> $env:GITHUB_ENV
- target: linux
os: ubuntu-latest
make: bash scripts/package-linux.sh package
artifact_path: |
echo "ARTIFACT_PATH=$(bash scripts/package-linux.sh archive_path)" >> "$GITHUB_ENV"
runs-on: ${{ matrix.target.os }}

steps:
Expand All @@ -31,14 +38,29 @@ jobs:
toolchain: stable
override: true

- name: Install linux deps
if: matrix.target.target == 'linux'
run: |
sudo apt install \
build-essential \
git \
pkg-config \
libdbus-1-dev \
libudev-dev \
libxkbcommon-dev \
libfontconfig1-dev

- name: Build
run: ${{ matrix.target.make }}

- name: Set artifact path
run: ${{ matrix.target.artifact_path }}

- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.target.target }}
path: ${{ matrix.target.binary_path }}
path: ${{ env.ARTIFACT_PATH }}

create-release:
needs: build
Expand Down Expand Up @@ -67,29 +89,38 @@ jobs:
matrix:
target:
- artifact: macos
artifact_name: halloy.dmg
asset_name: halloy.dmg
artifact_name: |
echo "ARTIFACT_NAME=halloy.dmg" >> "$GITHUB_ENV"
asset_type: application/octet-stream
- artifact: windows
artifact_name: halloy.exe
asset_name: halloy.exe
artifact_name: |
echo "ARTIFACT_NAME=halloy.exe" >> "$GITHUB_ENV"
asset_type: application/x-dosexec
- artifact: linux
artifact_name: |
echo "ARTIFACT_NAME=$(bash scripts/package-linux.sh archive_name)" >> "$GITHUB_ENV"
asset_type: application/gzip

runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3

- name: Download artifact
uses: actions/download-artifact@v2
with:
name: ${{ matrix.target.artifact }}
path: ${{ matrix.target.artifact }}

- name: Set artifact name
run: ${{ matrix.target.artifact_name }}

- name: Upload asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./${{ matrix.target.artifact }}/${{ matrix.target.artifact_name }}
asset_name: ${{ matrix.target.asset_name }}
asset_path: ./${{ matrix.target.artifact }}/${{ env.ARTIFACT_NAME }}
asset_name: ${{ env.ARTIFACT_NAME }}
asset_content_type: ${{ matrix.target.asset_type }}
6 changes: 3 additions & 3 deletions assets/flatpak/org.squidowl.halloy.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
"build-commands": [
"cargo --offline fetch --manifest-path Cargo.toml --verbose",
"cargo --offline build --release --verbose",
"install -Dm644 ./assets/logo_128px.png /app/share/icons/hicolor/128x128/apps/org.squidowl.halloy.png",
"install -Dm644 ./assets/halloy.appdata.xml /app/share/metainfo/org.squidowl.halloy.appdata.xml",
"install -Dm644 ./assets/halloy.desktop /app/share/applications/org.squidowl.halloy.desktop",
"install -Dm644 ./assets/linux/org.squidowl.halloy.png /app/share/icons/hicolor/128x128/apps/org.squidowl.halloy.png",
"install -Dm644 ./assets/linux/org.squidowl.halloy.appdata.xml /app/share/metainfo/org.squidowl.halloy.appdata.xml",
"install -Dm644 ./assets/linux/org.squidowl.halloy.desktop /app/share/applications/org.squidowl.halloy.desktop",
"install -Dm755 ./target/release/halloy -t /app/bin/"
],
"sources": [
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes
4 changes: 1 addition & 3 deletions scripts/flatpak.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#!/bin/bash
set -xe

scripts/generate-icons.sh

flatpak remote-add --if-not-exists --user flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install --noninteractive --user flathub org.freedesktop.Platform//22.08 org.freedesktop.Sdk//22.08 org.freedesktop.Sdk.Extension.rust-stable//22.08

flatpak install --noninteractive --user org.freedesktop.appstream-glib
flatpak run --env=G_DEBUG=fatal-criticals org.freedesktop.appstream-glib validate assets/halloy.appdata.xml
flatpak run --env=G_DEBUG=fatal-criticals org.freedesktop.appstream-glib validate assets/linux/org.squidowl.halloy.appdata.xml

python3 -m pip install toml aiohttp
curl -L 'https://github.com/flatpak/flatpak-builder-tools/raw/master/cargo/flatpak-cargo-generator.py' > /tmp/flatpak-cargo-generator.py
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate-icons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ src=logo.png
conv_opts="-colors 256 -background none -density 300"

# the linux icon
convert $conv_opts -resize "!128x128" "$src" "logo_128px.png"
convert $conv_opts -resize "!128x128" "$src" "linux/org.squidowl.halloy.png"
43 changes: 43 additions & 0 deletions scripts/package-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

ARCH="x86_64"
TARGET="halloy"
VERSION=$(cat VERSION)
PROFILE="release"
ASSETS_DIR="assets/linux"
RELEASE_DIR="target/$PROFILE"
BINARY="$RELEASE_DIR/$TARGET"
ARCHIVE_DIR="$RELEASE_DIR/archive"
ARCHIVE_NAME="$TARGET-$VERSION-$ARCH-linux.tar.gz"
ARCHIVE_PATH="$RELEASE_DIR/$ARCHIVE_NAME"

build() {
cargo build --profile $PROFILE
}

archive_name() {
echo $ARCHIVE_NAME
}

archive_path() {
echo $ARCHIVE_PATH
}

package() {
build

install -D $ASSETS_DIR/* -t $ARCHIVE_DIR
install -Dm755 $BINARY $ARCHIVE_DIR
tar czvf $ARCHIVE_PATH -C $ARCHIVE_DIR .

echo "Packaged archive: $ARCHIVE_PATH"
}

case "$1" in
"package") package;;
"archive_name") archive_name;;
"archive_path") archive_path;;
*)
echo "avaiable commands: package, archive_name, archive_path"
;;
esac
Loading