Skip to content

build: provide version at runtime #49

build: provide version at runtime

build: provide version at runtime #49

Workflow file for this run

name: Release
on:
push:
branches:
- main
workflow_dispatch:
jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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 dependencies
run: pnpm install
- name: Lint
run: pnpm lint
- name: Test
run: pnpm test
prepare:
needs: check
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 tsx 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='# 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} live-protocol' \
--hooks.before:release='git add src-tauri/tauri.conf.json src-tauri/Cargo.toml src-tauri/Cargo.lock'
--hooks.before:release='tsx scripts/set-version.ts ${version}'
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
permissions:
contents: read
pages: write
id-token: write
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deploy.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
- run: pnpm dlx tsx scripts/set-version.ts ${{ needs.prepare.outputs.version }}
- uses: actions/upload-pages-artifact@v3
with:
path: demo
- name: Deploy to GitHub Pages
id: deploy
uses: actions/deploy-pages@v4
- run: echo "Deployed ${{ needs.prepare.outputs.version }} to ${{ steps.deploy.outputs.page_url }} :tada:" >> $GITHUB_STEP_SUMMARY
release:
needs: prepare
name: Release for ${{ matrix.name }}
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: "Live Protocol __VERSION__"
args: ${{ matrix.args }}
- run: echo "Released ${{ needs.prepare.outputs.version }} for ${{ matrix.name }} :rocket:" >> $GITHUB_STEP_SUMMARY