CI #546
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- 'v*' | |
pull_request: | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '20.10.0' | |
- uses: pnpm/action-setup@v2 | |
name: Install pnpm | |
with: | |
version: 9 | |
run_install: false | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v4 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- run: pnpm install | |
- run: pnpm build | |
- run: pnpm test | |
startMaintenance: | |
name: Start Maintenance | |
runs-on: ubuntu-latest | |
needs: [build] | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- run: | | |
curl "${{ secrets.MAINTENANCE_ENDPOINT }}" \ | |
-sSf \ | |
-H 'Accept: application/json' \ | |
-H 'Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7' \ | |
-H 'Connection: keep-alive' \ | |
-H 'Content-Type: application/json' \ | |
--data-raw '{"type":"start","token":"${{ secrets.MAINTENANCE_TOKEN }}"}' \ | |
--compressed | |
deploy: | |
name: Update Server | |
runs-on: ubuntu-latest | |
needs: [startMaintenance] | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- run: echo "${{ secrets.SSHKEY }}" > key.pem | |
- run: chmod 600 key.pem | |
- run: | |
ssh -i key.pem ${{ secrets.USER }}@${{ secrets.HOST }} -o ConnectTimeout=1200 -o | |
StrictHostKeyChecking=no "cd ${{ secrets.DIR }} && git checkout . && git pull origin | |
master && ${{ secrets.INSTALL_COMMAND }} && ${{ secrets.BUILD_COMMAND }} && ${{ | |
secrets.RESTART_COMMAND }}" | |
changelog: | |
name: Changelog | |
runs-on: ubuntu-latest | |
needs: [deploy] | |
if: startsWith(github.ref, 'refs/tags/v') | |
outputs: | |
changelog: ${{ steps.build_changelog.outputs.changelog }} | |
steps: | |
- uses: actions/checkout@v4 | |
name: Checkout repository | |
with: | |
fetch-depth: 0 | |
- name: Retrieve current tag | |
run: | |
echo "CURRENT_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | | |
sed -n '1p')" >> "$GITHUB_ENV" | |
- name: Retrieve previous tag | |
run: | |
echo "PREV_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sed | |
-n '2p')" >> "$GITHUB_ENV" | |
- name: Build changelog | |
id: build_changelog | |
run: | | |
{ | |
echo "changelog<<EOF" | |
echo "$({ git log $PREV_TAG...$CURRENT_TAG --pretty=format:"- %s" | grep '^- feat' | sed 's/^- feat:/- New:/'; git log $PREV_TAG...$CURRENT_TAG --pretty=format:"- %s" | grep '^- fix' | sed 's/^- fix:/- Fixed/'; })" | |
echo EOF | |
} >> "$GITHUB_OUTPUT" | |
release: | |
name: Update Client | |
needs: [changelog] | |
if: startsWith(github.ref, 'refs/tags/v') | |
permissions: | |
contents: write | |
strategy: | |
matrix: | |
include: | |
- platform: 'macos-latest' # for Arm based macs (M1 and above). | |
args: '--target aarch64-apple-darwin' | |
- platform: 'macos-latest' # for Intel based macs. | |
args: '--target x86_64-apple-darwin' | |
- platform: 'ubuntu-latest' | |
args: '' | |
- platform: 'windows-latest' | |
args: '' | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '20.10.0' | |
- uses: pnpm/action-setup@v2 | |
name: Install pnpm | |
with: | |
version: 9 | |
run_install: false | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v4 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: install Rust stable | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: | |
${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' | |
|| '' }} | |
- name: install dependencies (ubuntu only) | |
if: matrix.platform == 'ubuntu-latest' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf | |
- run: pnpm install | |
- run: pnpm build:shared:noci | |
- run: pnpm build:noci | |
- uses: tauri-apps/tauri-action@v0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} | |
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} | |
with: | |
tagName: v__VERSION__ | |
releaseName: 'v__VERSION__' | |
releaseBody: | |
${{ needs.changelog.outputs.changelog || 'See the assets to download this version | |
and install it.' }} | |
releaseDraft: false | |
prerelease: false | |
args: ${{ matrix.args }} | |
endMaintenance: | |
name: End Maintenance | |
runs-on: ubuntu-latest | |
needs: [release] | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- run: | | |
curl "${{ secrets.MAINTENANCE_ENDPOINT }}" \ | |
-sSf \ | |
-H 'Accept: application/json' \ | |
-H 'Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7' \ | |
-H 'Connection: keep-alive' \ | |
-H 'Content-Type: application/json' \ | |
--data-raw '{"type":"end","token":"${{ secrets.MAINTENANCE_TOKEN }}"}' \ | |
--compressed |