Skip to content

Merge pull request #418 from dwall-rs/dev #403

Merge pull request #418 from dwall-rs/dev

Merge pull request #418 from dwall-rs/dev #403

Workflow file for this run

name: "nightly"
on:
push:
branches:
- main
jobs:
check-changed-paths:
runs-on: ubuntu-22.04
outputs:
changed: ${{ steps.changed-front.outputs.changed }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 100
- uses: marceloprado/[email protected]
id: changed-front
with:
paths: daemon public src src-tauri static package.json .scripts .github
- name: Check commit message for keywords
id: check-commit-message
run: |
COMMIT_MESSAGE=$(git log -1 --pretty=format:%s)
if [[ "$COMMIT_MESSAGE" =~ ^(feat|fix|breaking) ]]; then
echo "Commit message indicates a relevant change."
else
echo "No relevant commit detected. Skipping Nightly release."
exit 0
fi
create-release:
needs: check-changed-paths
if: needs.check-changed-paths.outputs.changed == 'true'
permissions:
contents: write
runs-on: ubuntu-22.04
outputs:
release_id: ${{ steps.create-release.outputs.result }}
package_version: ${{ env.PACKAGE_VERSION }}
steps:
- uses: actions/checkout@v4
- name: setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: get version
run: echo "PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
- name: get old nightly release id
run: |
release_id=$(curl -s 'https://api.github.com/repos/dwall-rs/dwall/releases/tags/nightly' | awk -F'[{},:]+' '/^ "id"/ {print $2}' | xargs)
echo "RELEASE_ID=$release_id" >> $GITHUB_ENV
- name: delete old nightly release
if: env.RELEASE_ID != ''
run: gh release delete nightly --cleanup-tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: create release
id: create-release
uses: actions/github-script@v7
with:
script: |
const { data } = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: "nightly",
name: "Nightly build",
draft: true,
prerelease: true,
})
return data.id
build-tauri:
needs: create-release
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- platform: "windows-latest"
args: ""
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: setup node
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Cache bun cache
uses: actions/cache@v4
with:
path: |
~\.bun
node_modules/
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
${{ runner.os }}-bun-
- uses: oven-sh/setup-bun@v1
- name: install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-msvc
- name: install frontend dependencies
run: bun i
- name: Cache Rust cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Restore cached target
id: cache-target-restore
uses: actions/cache/restore@v4
with:
path: |
target/
key: ${{ runner.os }}-target-${{ hashFiles('**/Cargo.lock') }}
- uses: tauri-apps/[email protected]
env:
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
releaseId: ${{ needs.create-release.outputs.release_id }}
args: ${{ matrix.args }} --config src-tauri/tauri.debug.conf.json
- name: Save target
id: cache-target-save
uses: actions/cache/save@v4
with:
path: |
target/
key: ${{ steps.cache-target-restore.outputs.cache-primary-key }}
publish-release:
permissions:
contents: write
runs-on: ubuntu-22.04
needs: [create-release, build-tauri]
steps:
- name: publish release
id: publish-release
uses: actions/github-script@v7
env:
release_id: ${{ needs.create-release.outputs.release_id }}
PACKAGE_VERSION: ${{ needs.create-release.outputs.package_version }}
LAST_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
with:
script: |
github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: parseInt(process.env.release_id),
body: `> [!WARNING]\n> 每夜版可能无法自动升级。/The nightly version may not auto-update.\n\nThe log level of the nightly version is fixed to ${"`debug`"}. If an error occurs while running this program, you can install the nightly version, repeat the previous operation, and then view the detailed logs.\n\n## Last Commit\n\n${process.env.LAST_COMMIT_MESSAGE}`,
draft: false
})