feat: add bump input to release workflow for versioning control #12
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: 'Build' | |
on: | |
push: | |
branches: | |
- dev | |
workflow_dispatch: | |
inputs: | |
channel: | |
type: choice | |
required: true | |
description: channel | |
default: dev | |
options: | |
- release | |
- dev | |
bump: | |
type: choice | |
required: true | |
description: update type | |
default: patch | |
options: | |
- undefined | |
- patch | |
- minor | |
- major | |
jobs: | |
build-sveltekit: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: consume vars | |
shell: bash | |
run: | | |
echo "channel=${{ github.event.inputs.channel || 'dev' }}" >> $GITHUB_ENV | |
echo "bump=${{ github.event.inputs.bump || 'patch' }}" >> $GITHUB_ENV | |
- name: calculate next version | |
shell: bash | |
run: | | |
CURRENT_VERSION="$(curl -s "https://api.github.com/repos/nneewwoo/seminar-assess/tags" | jq -r 'if . == [] then "0.0.0" else .[0].name end')" | |
NEXT_VERSION=$(./scripts/next.sh "${CURRENT_VERSION}" "${{ env.bump }}") | |
echo "version=$NEXT_VERSION" >> $GITHUB_ENV | |
mkdir -p release && echo "$NEXT_VERSION" > release/version | |
- name: setup pnpm | |
uses: pnpm/action-setup@v4 | |
- name: setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
cache: pnpm | |
- name: build android frontend | |
run: pnpm build:android -- --mode production | |
- name: upload build output | |
uses: actions/upload-artifact@v4 | |
with: | |
name: sveltekit-build | |
path: ./apps/android/build | |
retention-days: 1 | |
if-no-files-found: error | |
build-tauri: | |
needs: build-sveltekit | |
env: | |
CARGO_TERM_COLOR: always | |
permissions: | |
contents: write | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- platform: 'ubuntu-24.04' | |
mobile: true | |
android: true | |
args: '' | |
runs-on: ${{ matrix.platform }} | |
outputs: | |
platform: ${{ matrix.platform }} | |
channel: ${{ env.channel }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: consume vars | |
shell: bash | |
run: | | |
echo "channel=${{ github.event.inputs.channel || 'dev' }}" >> $GITHUB_ENV | |
echo "bump=${{ github.event.inputs.bump || 'patch' }}" >> $GITHUB_ENV | |
- name: calculate next version | |
shell: bash | |
run: | | |
CURRENT_VERSION="$(curl -s "https://api.github.com/repos/nneewwoo/seminar-assess/tags" | jq -r 'if . == [] then "0.0.0" else .[0].name end')" | |
NEXT_VERSION=$(./scripts/next.sh "${CURRENT_VERSION}" "${{ env.bump }}") | |
echo "version=$NEXT_VERSION" >> $GITHUB_ENV | |
mkdir -p release && echo "$NEXT_VERSION" > release/version | |
- name: install linux dependencies | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf | |
- name: setup pnpm | |
uses: pnpm/action-setup@v4 | |
- name: setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
cache: pnpm | |
- name: setup Rust nightly | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
- name: setup Java | |
if: matrix.mobile | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: '17' | |
- name: Setup Android SDK (Android only) | |
if: matrix.mobile | |
uses: android-actions/setup-android@v3 | |
- name: Install NDK (Android only) | |
if: matrix.mobile | |
run: sdkmanager "ndk;27.0.11902837" | |
- name: setup Android signing (Android only) | |
if: matrix.mobile | |
run: | | |
cd crates/seminar-assess-tauri/gen/android | |
echo "keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}" > keystore.properties | |
echo "password=${{ secrets.ANDROID_KEY_PASSWORD }}" >> keystore.properties | |
base64 -d <<< "${{ secrets.ANDROID_KEY_BASE64 }}" > $RUNNER_TEMP/keystore.jks | |
echo "storeFile=$RUNNER_TEMP/keystore.jks" >> keystore.properties | |
- uses: actions/download-artifact@v4 | |
with: | |
name: sveltekit-build | |
path: ./apps/android/build | |
- name: build tauri | |
shell: bash | |
run: | | |
./scripts/release.sh \ | |
--sign \ | |
--channel ${{ env.channel }}" \ | |
--dist "./release" \ | |
--version ${{ env.version}}" | |
- name: upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: '${{ env.channel }}-${{ matrix.platform }}-${{ github.run_number }}' | |
path: release/ | |
if-no-files-found: error | |
publish-release: | |
needs: build-tauri | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- platform: 'ubuntu-24.04' | |
mobile: true | |
android: true | |
args: '' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: consume vars | |
shell: bash | |
run: | | |
echo "channel=${{ github.event.inputs.channel || 'dev' }}" >> $GITHUB_ENV | |
echo "bump=${{ github.event.inputs.bump || 'patch' }}" >> $GITHUB_ENV | |
- name: download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: '${{ needs.build-tauri.outputs.channel }}-${{ matrix.platform }}-${{ github.run_number }}' | |
path: release | |
- name: calculate next version | |
shell: bash | |
run: | | |
CURRENT_VERSION="$(curl -s "https://api.github.com/repos/nneewwoo/seminar-assess/tags" | jq -r 'if . == [] then "0.0.0" else .[0].name end')" | |
NEXT_VERSION=$(./scripts/next.sh "${CURRENT_VERSION}" "${{ env.bump }}") | |
echo "version=$NEXT_VERSION" >> $GITHUB_ENV | |
mkdir -p release && echo "$NEXT_VERSION" > release/version | |
- name: create release | |
uses: softprops/action-gh-release@v2 | |
if: startsWith(github.ref, 'refs/heads/') | |
with: | |
files: ./release/* | |
tag_name: v${{ env.version }} | |
name: 'Release v${{ env.version }} - ${{ env.channel }}' | |
body: | | |
Test release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |