Skip to content

Fix dropdown

Fix dropdown #14

Workflow file for this run

name: Release
on:
workflow_dispatch:
push:
tags:
- "v*"
permissions:
contents: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
prerelease: ${{ steps.version.outputs.prerelease }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Read Cargo version and validate tag
id: version
shell: bash
run: |
set -euo pipefail
version="$(grep -m 1 '^version = "' src-tauri/Cargo.toml | cut -d '"' -f 2)"
if [[ -z "${version}" ]]; then
echo "Could not read version from src-tauri/Cargo.toml" >&2
exit 1
fi
expected_tag="v${version}"
if [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then
tag="${GITHUB_REF_NAME}"
if [[ "${tag}" != "${expected_tag}" ]]; then
echo "Tag ${tag} does not match src-tauri version ${version}" >&2
exit 1
fi
else
tag="${expected_tag}"
fi
if [[ "${version}" == *-* ]]; then
prerelease=true
else
prerelease=false
fi
echo "version=${version}" >> "${GITHUB_OUTPUT}"
echo "tag=${tag}" >> "${GITHUB_OUTPUT}"
echo "prerelease=${prerelease}" >> "${GITHUB_OUTPUT}"
frontend-assets:
runs-on: ubuntu-24.04
env:
CARGO_TERM_COLOR: always
NO_COLOR: "false"
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Add cargo bin directory to PATH
shell: bash
run: echo "${HOME}/.cargo/bin" >> "${GITHUB_PATH}"
- name: Install Rust toolchain
shell: bash
run: |
set -euo pipefail
rustup toolchain install stable --allow-downgrade
rustup default stable
rustup target add wasm32-unknown-unknown
- name: Install frontend build dependencies
shell: bash
run: |
set -euo pipefail
cargo install --locked trunk
cargo install --locked wasm-bindgen-cli
npm install --global --save-exact esbuild
npm install --global tailwindcss
npm install --global --save-exact sass
- name: Build frontend assets
shell: bash
run: |
set -euo pipefail
NO_COLOR=false trunk build
- name: Upload frontend assets
uses: actions/upload-artifact@v4
with:
name: frontend-dist
path: src-ui/dist
if-no-files-found: error
build:
needs:
- prepare
- frontend-assets
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-24.04
target: x86_64-unknown-linux-gnu
os_name: linux
arch: x86_64
bundles: appimage,deb,rpm
- runner: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
os_name: linux
arch: arm64
bundles: appimage,deb,rpm
- runner: macos-15-intel
target: x86_64-apple-darwin
os_name: macos
arch: x86_64
bundles: dmg
artifact_name: macos-x86_64
- runner: macos-15
target: aarch64-apple-darwin
os_name: macos
arch: arm64
bundles: dmg
artifact_name: macos-arm64
- runner: windows-2025
target: x86_64-pc-windows-msvc
os_name: windows
arch: x86_64
bundles: ""
artifact_name: windows-x86_64
- runner: windows-11-arm
target: aarch64-pc-windows-msvc
os_name: windows
arch: arm64
bundles: ""
artifact_name: windows-arm64
runs-on: ${{ matrix.runner }}
env:
CARGO_TERM_COLOR: always
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
NO_COLOR: "false"
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Add cargo bin directory to PATH
shell: bash
run: echo "${HOME}/.cargo/bin" >> "${GITHUB_PATH}"
- name: Install Rust toolchain
shell: bash
run: |
set -euo pipefail
rustup toolchain install stable --allow-downgrade
rustup default stable
rustup target add wasm32-unknown-unknown "${{ matrix.target }}"
- name: Install Linux build dependencies
if: startsWith(matrix.runner, 'ubuntu-')
shell: bash
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
libgtk-3-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
patchelf \
pkg-config \
libssl-dev \
libfuse2t64 \
rpm
- name: Install README build dependencies
shell: bash
run: |
set -euo pipefail
cargo install tauri-cli --version "^2.0.0" --locked
cargo install --locked trunk
cargo install --locked wasm-bindgen-cli
npm install --global --save-exact esbuild
npm install --global tailwindcss
- name: Fetch Cargo dependencies
shell: bash
run: |
set -euo pipefail
cargo fetch
- name: Download frontend assets
if: matrix.os_name == 'windows'
uses: actions/download-artifact@v4
with:
name: frontend-dist
path: src-ui/dist
- name: Build release bundles
shell: bash
run: |
set -euo pipefail
if [[ "${{ matrix.os_name }}" == "windows" ]]; then
cargo tauri build --ci --no-sign --no-bundle --target "${{ matrix.target }}" --config '{"build":{"beforeBuildCommand":""}}'
else
cargo tauri build --ci --no-sign --bundles "${{ matrix.bundles }}" --target "${{ matrix.target }}"
fi
- name: Stage release artifacts
shell: bash
env:
VERSION: ${{ needs.prepare.outputs.version }}
OS_NAME: ${{ matrix.os_name }}
ARCH: ${{ matrix.arch }}
TARGET: ${{ matrix.target }}
run: |
set -euo pipefail
bundle_dir="target/${TARGET}/release/bundle"
stage_dir="ci-dist"
mkdir -p "${stage_dir}"
case "${OS_NAME}" in
linux)
cp "${bundle_dir}/appimage/"*.AppImage "${stage_dir}/WriterMD_${VERSION}_${OS_NAME}_${ARCH}.AppImage"
cp "${bundle_dir}/deb/"*.deb "${stage_dir}/WriterMD_${VERSION}_${OS_NAME}_${ARCH}.deb"
cp "${bundle_dir}/rpm/"*.rpm "${stage_dir}/WriterMD_${VERSION}_${OS_NAME}_${ARCH}.rpm"
;;
macos)
cp "${bundle_dir}/dmg/"*.dmg "${stage_dir}/WriterMD_${VERSION}_${OS_NAME}_${ARCH}.dmg"
;;
windows)
cp "target/${TARGET}/release/src_tauri.exe" "${stage_dir}/WriterMD_${VERSION}_${OS_NAME}_${ARCH}.exe"
;;
*)
echo "Unsupported OS ${OS_NAME}" >&2
exit 1
;;
esac
- name: Upload staged artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os_name }}-${{ matrix.arch }}
path: ci-dist/*
if-no-files-found: error
- name: Upload Linux AppImage artifact
if: matrix.os_name == 'linux'
uses: actions/upload-artifact@v4
with:
name: linux-appimage-${{ matrix.arch }}
path: ci-dist/*.AppImage
if-no-files-found: error
- name: Upload Linux deb artifact
if: matrix.os_name == 'linux'
uses: actions/upload-artifact@v4
with:
name: linux-deb-${{ matrix.arch }}
path: ci-dist/*.deb
if-no-files-found: error
- name: Upload Linux rpm artifact
if: matrix.os_name == 'linux'
uses: actions/upload-artifact@v4
with:
name: linux-rpm-${{ matrix.arch }}
path: ci-dist/*.rpm
if-no-files-found: error
publish:
needs:
- prepare
- build
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
VERSION: ${{ needs.prepare.outputs.version }}
TAG: ${{ needs.prepare.outputs.tag }}
PRERELEASE: ${{ needs.prepare.outputs.prerelease }}
steps:
- name: Download staged artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Create or update GitHub Release
shell: bash
run: |
set -euo pipefail
shopt -s nullglob
files=()
while IFS= read -r file; do
files+=("${file}")
done < <(find dist -maxdepth 1 -type f | sort)
if [[ ${#files[@]} -eq 0 ]]; then
echo "No release files found" >&2
exit 1
fi
if gh release view "${TAG}" >/dev/null 2>&1; then
gh release upload "${TAG}" "${files[@]}" --clobber
else
prerelease_flag=()
if [[ "${PRERELEASE}" == "true" ]]; then
prerelease_flag+=(--prerelease)
fi
gh release create "${TAG}" "${files[@]}" \
--title "WriterMD v${VERSION}" \
--generate-notes \
"${prerelease_flag[@]}"
fi