Skip to content

build

build #63

Workflow file for this run

name: 'build'
on:
workflow_dispatch:
push:
tags:
- v**
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
download-dbip:
runs-on: ubuntu-latest
steps:
- name: Download dbip database
run: wget -nv -O- "https://download.db-ip.com/free/dbip-country-lite-2024-10.mmdb.gz" | zcat > dbip.mmdb
- uses: actions/upload-artifact@v3
with:
name: dbip
path: "dbip.mmdb"
build-binaries:
needs: download-dbip
strategy:
fail-fast: false
matrix:
platform:
- os: ubuntu-latest
rust_target: x86_64-unknown-linux-gnu
- os: macos-latest
rust_target: x86_64-apple-darwin
- os: macos-latest
rust_target: aarch64-apple-darwin
- os: windows-latest
rust_target: x86_64-pc-windows-msvc
- os: windows-latest
rust_target: aarch64-pc-windows-msvc
runs-on: ${{ matrix.platform.os }}
steps:
- name: Disable crlf
if: matrix.platform.os == 'windows-latest'
run: |
git config --global core.autocrlf input
- uses: actions/checkout@v3
# Download the previously uploaded artifacts
- uses: actions/download-artifact@v3
id: download
with:
name: dbip
path: src-tauri/
- name: setup node
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- name: 'Setup Rust'
if: matrix.platform.rust_target == 'aarch64-apple-darwin' || matrix.platform.rust_target == 'x86_64-apple-darwin' || matrix.platform.rust_target == 'aarch64-pc-windows-msvc'
run: rustup target add ${{matrix.platform.rust_target}}
- uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ matrix.platform.rust_target }}
workspaces: |
src-tauri
- name: install dependencies (ubuntu only)
if: matrix.platform.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libasound2-dev libfontconfig-dev
- name: install npm packages
run: npm ci
- uses: JonasKruckenberg/tauri-build@v1
id: tauri_build
with:
target: ${{ matrix.platform.rust_target }}
- name: Git status and version
run: |
git status
git describe --tags --dirty --always
git diff
# The artifacts output can now be used to upload the artifacts
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.platform.rust_target }}
path: "${{ join(fromJSON(steps.tauri_build.outputs.artifacts), '\n') }}"
- name: pack webapp
if: matrix.platform.os == 'ubuntu-latest'
working-directory: dist
id: pack-webapp
run: |
GIT_VERSION=`git describe --tags --always`
zip -9 -r "trguing-web-$GIT_VERSION.zip" ./* -x create\* -x \*.map -x \*flag-icons\*
echo "ZIPFILE=trguing-web-$GIT_VERSION.zip" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v3
if: matrix.platform.os == 'ubuntu-latest'
with:
name: build web
path: "dist/${{ steps.pack-webapp.outputs.ZIPFILE }}"
publish:
needs: build-binaries
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
# Download the previously uploaded artifacts
- uses: actions/download-artifact@v3
id: download
with:
path: artifacts
- name: Rename mac app archives
run: |
mv artifacts/x86_64-apple-darwin/TrguiNG.app.tar.gz artifacts/x86_64-apple-darwin/TrguiNG_x86_64.app.tar.gz
mv artifacts/aarch64-apple-darwin/TrguiNG.app.tar.gz artifacts/aarch64-apple-darwin/TrguiNG_aarch64.app.tar.gz
- name: Downloaded artifacts
run: ls -lhR artifacts/
# Generate chagnelog
- id: prevtag
run: |
PREVIOUS_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo '')
echo "previous_tag=$PREVIOUS_TAG" >> $GITHUB_OUTPUT
- name: Generate changelog
id: changelog
uses: jaywcjlove/changelog-generator@main
if: steps.prevtag.outputs.previous_tag
with:
token: ${{ secrets.GITHUB_TOKEN }}
show-emoji: false
# And create a release with the artifacts attached
- name: 'create release'
uses: softprops/action-gh-release@v0.1.15
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
with:
draft: true
files: ./artifacts/**/*
body: |
${{ steps.changelog.outputs.compareurl }}
${{ steps.changelog.outputs.changelog }}
update_aur:
name: Publish AUR package
needs: build-binaries
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Determine version
id: determine-version
run: |
GIT_VERSION=`git describe --tags --always`
echo "GIT_VERSION=$GIT_VERSION" >> $GITHUB_OUTPUT
# Download the previously uploaded artifacts
- uses: actions/download-artifact@v3
id: download
with:
name: dbip
- name: Download desktop file
run: wget -nv -O TrguiNG.desktop "https://raw.githubusercontent.com/flathub/org.openscopeproject.TrguiNG/master/org.openscopeproject.TrguiNG.desktop"
- name: Generate PKGBUILD
run: |
python3 ci/generate_pkgbuild.py
cat PKGBUILD
- name: Publish to the AUR
uses: KSXGitHub/github-actions-deploy-aur@v3.0.1
with:
pkgname: trgui-ng
pkgbuild: ./PKGBUILD
commit_username: ${{ secrets.AUR_USERNAME }}
commit_email: ${{ secrets.AUR_EMAIL }}
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: Update to ${{ steps.determine-version.outputs.GIT_VERSION }}