Skip to content

Build and Prerelease #10

Build and Prerelease

Build and Prerelease #10

Workflow file for this run

name: Build and Prerelease
permissions:
contents: write
actions: read
on:
workflow_dispatch:
push:
paths-ignore:
- '**.md'
- '**.yaml'
- '**.yml'
branches:
- main
jobs:
version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.semantic-version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- id: semantic-version
uses: paulhatch/semantic-version@v5.4.0
with:
tag_prefix: 'v'
# A string which, if present in a git commit, indicates that a change represents a
# major (breaking) change, supports regular expressions wrapped with '/'
major_pattern: "MAJOR"
# Same as above except indicating a minor change, supports regular expressions wrapped with '/'
minor_pattern: "MINOR"
# A string to determine the format of the version output
version_format: "${major}.${minor}.${patch}"
# If this is set to true, *every* commit will be treated as a new version.
# bump_each_commit: true
pre-release:
runs-on: ubuntu-latest
needs: version
env:
OPEN_AI_API_KEY: ${{ secrets.OPEN_AI_API_KEY }}
GOOGLE_CLOUD_API_KEY: ${{ secrets.GOOGLE_CLOUD_API_KEY }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: 3.32.8
cache: true
- run: flutter --version
- name: Update pubspec.yaml version
run: |
# Update the version in pubspec.yaml with the semantic version
sed -i "s/^version: .*/version: ${{ needs.version.outputs.version }}+${{ github.run_number }}/g" pubspec.yaml
echo "Updated pubspec.yaml version to: ${{ needs.version.outputs.version }}+${{ github.run_number }}"
# Verify the change
grep "^version:" pubspec.yaml
- name: Install dependencies
run: flutter pub get
- name: Generate code
run: dart run build_runner build --delete-conflicting-outputs
- name: Build web
run: flutter build web
- name: Create build artifact zip
run: |
cd build/web
zip -r ../../build-artifacts-${{ needs.version.outputs.version }}.zip .
cd ../..
- name: Create Pre-release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.version.outputs.version }}
name: Release v${{ needs.version.outputs.version }}
body: |
## What's Changed
Build artifacts for version ${{ needs.version.outputs.version }}
- App version updated to: ${{ needs.version.outputs.version }}+${{ github.run_number }}
- Built from commit: ${{ github.sha }}
draft: false
prerelease: true
generate_release_notes: true
target_commitish: ${{ github.ref_name }}
files: build-artifacts-${{ needs.version.outputs.version }}.zip