Skip to content

Commit

Permalink
feat: distribute packaged installers
Browse files Browse the repository at this point in the history
  • Loading branch information
decipher3114 committed Sep 8, 2024
1 parent 74b5712 commit ae7345f
Show file tree
Hide file tree
Showing 16 changed files with 157 additions and 44 deletions.
126 changes: 85 additions & 41 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,118 @@ name: Release

permissions:
contents: write
pull-requests: write

on:
push:
tags:
- v[0-9]+.*


jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Update CHANGELOG
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ github.token }}
tag: ${{ github.ref_name }}

- name: Create Release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: |
${{ steps.changelog.outputs.changes }}
draft: false
prerelease: false

upload-assets:
needs: create-release
build-assets:
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
format: "deb,pacman"
- target: x86_64-apple-darwin
os: macos-latest
format: "app,dmg"
- target: x86_64-pc-windows-msvc
os: windows-latest
format: "wix,nsis"
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: apt Cache
- name: Setup Linux
if: matrix.os == 'ubuntu-latest'
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libgtk-3-dev libxdo-dev libappindicator3-dev
version: 1.0

- name: Setup toolchain
run: rustup toolchain install stable --profile minimal
- name: Setup Windows
if: matrix.os == 'windows-latest'
run: |
dotnet tool install --global wix
$base64Cert = '${{ secrets.WINDOWS_CERT }}'
[System.IO.File]::WriteAllBytes("certificate.pfx", [System.Convert]::FromBase64String($base64Cert))
$password = ConvertTo-SecureString -String '${{ secrets.WINDOWS_CERT_PASSWORD }}' -Force -AsPlainText
Import-PfxCertificate -FilePath 'certificate.pfx' -CertStoreLocation 'Cert:\\CurrentUser\\My' -Password $password
- name: Rust Cache
uses: Swatinem/rust-cache@v2

- name: Build ${{ matrix.target }}
uses: taiki-e/upload-rust-binary-action@v1
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
bin: Capter
toolchain: stable
target: ${{ matrix.target }}
tar: unix
zip: windows
token: ${{ github.token }}

- name: Build binary
run: |
cargo build --release
- name: Install cargo-packager
run: |
cargo install cargo-packager --locked
- name: Package binary
run: |
cargo packager --release --formats ${{ matrix.format }} -v
- name: Upload windows artifacts
uses: actions/upload-artifact@v4
if: matrix.os == 'windows-latest'
with:
name: windows_packages
path: |
target/packages/*.msi
target/packages/*.exe
- name: Upload linux artifacts
uses: actions/upload-artifact@v4
if: matrix.os == 'ubuntu-latest'
with:
name: linux_packages
path: |
target/packages/*.deb
target/packages/*.tar.gz
- name: Upload macos artifacts
uses: actions/upload-artifact@v4
if: matrix.os == 'macos-latest'
with:
name: macos_packages
path: |
target/packages/*.dmg
target/packages/*.app
upload-assets:
needs: build-assets
runs-on: 'ubuntu-latest'
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Update CHANGELOG
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ github.token }}
tag: ${{ github.ref_name }}

- name: Download Artifact
uses: actions/download-artifact@v4

- name: Release
uses: softprops/action-gh-release@v2
with:
name: ${{ github.ref_name }}
body: |
${{ steps.changelog.outputs.changes }}
files: |
windows_packages/*
linux_packages/*
macos_packages/*
draft: false
prerelease: false
29 changes: 27 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "1.0.1"
description = "A simple cross-platform screenshot tool"
edition = "2021"
authors = ["decipher3114 <decipher3114@gmail.com>"]
build = "build.rs"

[dependencies]
active-win-pos-rs = "0.8.3"
Expand All @@ -18,3 +19,38 @@ tokio = { version = "1.39.2", features = ["full", "rt"] }
toml = "0.8.19"
tray-icon = "0.17.0"
xcap = "0.0.13"

[target.'cfg( target_os = "windows" )'.build-dependencies]
winresource = "0.1"

[package.metadata.winresource]
ProductName = "Capter"

[package.metadata.packager]
product-name = "Capter"
version = "1.0.1"
identifier = "app.decipher.capter"
authors = ["decipher3114 <decipher3114@gmail.com>"]
publisher = "decipher3114"
category = "utility"
copyright = "Copyright © 2024"
before-packaging-command = "cargo build --release"
icons = ["assets/icons/windows/icon.ico", "assets/icons/macos/icon.icns", "assets/icons/linux/*"]
out-dir = "target/packages"

[package.metadata.packager.nsis]
installer-icon = "assets/icons/windows/icon.ico"
installer-mode = "perMachine"

[package.metadata.packager.windows]
digest-algorithim = "SHA256"
certificate-thumbprint = "07a9c417660868a4420fe9e2f8b6ac2e1a33228a"
tsp = true
timestamp-url = "http://timestamp.digicert.com"

[package.metadata.packager.deb]
depends = ["libgtk-3-dev", "libxdo-dev", "libayatana-appindicator3-dev", "libxcb1", "libxrandr2", "libdbus-1-3"]

[package.metadata.packager.pacman]
source = ["${pkgname}-${pkgver}.tar.gz::https://github.com/Capter/releases/latest/download/Capter_${pkgver}_x86_64.tar.gz"]
depends = ["gtk3", "xdotool", "libayatana-appindicator", "libxcb", "libxrandr", "dbus"]
Binary file modified assets/icons/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/linux/128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/linux/128@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/linux/256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/linux/256@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/linux/32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/linux/32@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/linux/48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/linux/48@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/macos/icon.icns
Binary file not shown.
Binary file added assets/icons/windows/icon.ico
Binary file not shown.
8 changes: 8 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fn main() {
#[cfg(target_os = "windows")]
{
let mut res = winresource::WindowsResource::new();
res.set_icon("assets/icons/windows/icon.ico");
res.compile().unwrap();
}
}
2 changes: 1 addition & 1 deletion src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub const FONT_MEDIUM: &[u8; 86616] = include_bytes!("../assets/fonts/SpaceGrote

pub const FONT_BOLD: &[u8; 86520] = include_bytes!("../assets/fonts/SpaceGrotesk-Bold.ttf");

pub const ICON: &[u8; 629] = include_bytes!("../assets/icons/icon.png");
pub const ICON: &[u8; 1358] = include_bytes!("../assets/icons/icon.png");

pub const SVG_FOLDER_OPEN: &[u8; 653] = include_bytes!("../assets/icons/folder-open.svg");

Expand Down

0 comments on commit ae7345f

Please sign in to comment.