docs: improve readme #41
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: Release | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
prepare: | |
name: Prepare | |
permissions: | |
contents: write | |
id-token: write | |
outputs: | |
hash: ${{ steps.result.outputs.hash }} | |
version: ${{ steps.result.outputs.version }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
fetch-tags: true | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 9.9.0 | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
cache: "pnpm" | |
- name: Install Rust stable | |
uses: dtolnay/rust-toolchain@stable | |
- name: Setup Rust cache | |
uses: swatinem/rust-cache@v2 | |
with: | |
workspaces: "./src-tauri -> target" | |
- name: Install dependencies | |
run: | | |
pnpm install --global release-it @release-it/conventional-changelog | |
cargo install cargo-bump | |
- name: Prepare release | |
run: | | |
git config user.email "${{ vars.GIT_EMAIL }}" | |
git config user.name "${{ vars.GIT_USER }}" | |
release-it \ | |
--ci \ | |
--npm.skipChecks \ | |
--no-npm.publish \ | |
--github.release \ | |
--github.autoGenerate \ | |
--git.commitMessage='chore: release ${version} [skip actions]' \ | |
--git.pushArgs=--follow-tags \ | |
--plugins.@release-it/conventional-changelog.infile=CHANGELOG.md \ | |
--plugins.@release-it/conventional-changelog.header='# Xmind Live Protocol' \ | |
--plugins.@release-it/conventional-changelog.preset=angular \ | |
--hooks.before:release='echo "$(jq '\''.version="${version}"'\'' src-tauri/tauri.conf.json)" > src-tauri/tauri.conf.json' \ | |
--hooks.before:release='cargo bump --manifest-path src-tauri/Cargo.toml ${version}' \ | |
--hooks.before:release='cargo update --manifest-path src-tauri/Cargo.toml --precise ${version} xmind-live-protocol' \ | |
--hooks.before:release='git add src-tauri/tauri.conf.json src-tauri/Cargo.toml src-tauri/Cargo.lock' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Provide version and commit hash | |
id: result | |
run: | | |
echo "hash=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" | |
echo "version=$(node -e "console.log(require('./package.json').version);")" >> "$GITHUB_OUTPUT" | |
deploy: | |
needs: prepare | |
name: Deploy ${{ needs.prepare.outputs.version }} | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
runs-on: ubuntu-latest | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v4 | |
with: | |
version: 9.9.0 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: .nvmrc | |
cache: pnpm | |
- run: pnpm install | |
- run: ./node_modules/.bin/vite build --mode detached | |
- uses: actions/upload-pages-artifact@v3 | |
with: | |
path: dist | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
- run: echo "Deployed ${{ needs.prepare.outputs.version }} to ${{ steps.deployment.outputs.page_url }} :tada:" >> $GITHUB_STEP_SUMMARY | |
release: | |
needs: prepare | |
name: Release ${{ needs.prepare.outputs.version }} | |
permissions: | |
contents: write | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- name: "macOS (Apple Silicon)" | |
platform: "macos-latest" | |
args: "--target aarch64-apple-darwin" | |
- name: "macOS (Intel)" | |
platform: "macos-latest" | |
args: "--target x86_64-apple-darwin" | |
- name: "Ubuntu" | |
platform: "ubuntu-22.04" | |
args: "" | |
- name: "Windows" | |
platform: "windows-latest" | |
args: "" | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.prepare.outputs.hash }} | |
fetch-depth: 0 | |
fetch-tags: true | |
- name: Install dependencies (ubuntu only) | |
if: matrix.platform == 'ubuntu-22.04' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 9.9.0 | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
cache: "pnpm" | |
- name: Install Rust stable | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
# Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds. | |
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }} | |
- name: Setup Rust cache | |
uses: swatinem/rust-cache@v2 | |
with: | |
workspaces: "./src-tauri -> target" | |
- name: Install dependencies | |
run: pnpm install | |
- uses: tauri-apps/tauri-action@v0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tagname: __VERSION__ | |
releaseName: "Xmind Live Protocol __VERSION__" | |
args: ${{ matrix.args }} | |
- run: echo "Released ${{ needs.prepare.outputs.version }} for ${{ matrix.name }} :rocket:" >> $GITHUB_STEP_SUMMARY |