Add Stately AI/XState documentation for exploration #28
This file contains hidden or 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: | |
| inputs: | |
| force_release: | |
| description: 'Force release even for patch versions' | |
| required: false | |
| default: 'true' | |
| type: boolean | |
| concurrency: | |
| group: release | |
| cancel-in-progress: false | |
| jobs: | |
| check-version: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_release: ${{ steps.check.outputs.should_release }} | |
| version: ${{ steps.check.outputs.version }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check for major/minor version change | |
| id: check | |
| run: | | |
| # Get current version from package.json | |
| CURRENT_VERSION=$(jq -r '.version' package.json) | |
| echo "Current version: $CURRENT_VERSION" | |
| # Extract major.minor from current version | |
| CURRENT_MAJOR_MINOR=$(echo "$CURRENT_VERSION" | cut -d. -f1,2) | |
| echo "Current major.minor: $CURRENT_MAJOR_MINOR" | |
| # Get the latest tag (if any) | |
| LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") | |
| echo "Latest tag: $LATEST_TAG" | |
| if [ -z "$LATEST_TAG" ]; then | |
| echo "No previous tags found - this will be the first release" | |
| echo "should_release=true" >> $GITHUB_OUTPUT | |
| echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| else | |
| # Remove 'v' prefix if present | |
| PREVIOUS_VERSION=${LATEST_TAG#v} | |
| echo "Previous version: $PREVIOUS_VERSION" | |
| # Extract major.minor from previous version | |
| PREVIOUS_MAJOR_MINOR=$(echo "$PREVIOUS_VERSION" | cut -d. -f1,2) | |
| echo "Previous major.minor: $PREVIOUS_MAJOR_MINOR" | |
| if [ "$CURRENT_MAJOR_MINOR" != "$PREVIOUS_MAJOR_MINOR" ]; then | |
| echo "Major or minor version changed - triggering release" | |
| echo "should_release=true" >> $GITHUB_OUTPUT | |
| echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| elif [ "${{ github.event.inputs.force_release }}" == "true" ]; then | |
| echo "Manual trigger with force_release - triggering release" | |
| echo "should_release=true" >> $GITHUB_OUTPUT | |
| echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| else | |
| echo "Only patch version changed - skipping release" | |
| echo "should_release=false" >> $GITHUB_OUTPUT | |
| echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| fi | |
| fi | |
| build: | |
| needs: check-version | |
| if: needs.check-version.outputs.should_release == 'true' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: windows-latest | |
| platform: windows | |
| - os: macos-latest | |
| platform: macos | |
| - os: ubuntu-latest | |
| platform: linux | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build and package | |
| run: npm run make | |
| - name: List output files | |
| shell: bash | |
| run: find out/make -type f 2>/dev/null || dir out\make /s /b | |
| - name: Stage artifacts (Unix) | |
| if: matrix.platform != 'windows' | |
| shell: bash | |
| run: | | |
| mkdir -p staged | |
| find out/make -type f \( -name "*.zip" -o -name "*.dmg" -o -name "*.deb" -o -name "*.rpm" \) -exec cp {} staged/ \; | |
| - name: Stage artifacts (Windows) | |
| if: matrix.platform == 'windows' | |
| shell: pwsh | |
| run: | | |
| New-Item -ItemType Directory -Force -Path staged | |
| Get-ChildItem -Path out/make -Recurse -Include *.exe,*.nupkg | Copy-Item -Destination staged/ | |
| # Copy RELEASES file if exists (for Squirrel) | |
| Get-ChildItem -Path out/make -Recurse -Filter "RELEASES" | Copy-Item -Destination staged/ | |
| - name: Generate latest.yml for electron-updater (Windows) | |
| if: matrix.platform == 'windows' | |
| shell: pwsh | |
| run: | | |
| $version = (Get-Content package.json | ConvertFrom-Json).version | |
| $exe = Get-ChildItem -Path staged -Filter "*.exe" | Select-Object -First 1 | |
| if ($exe) { | |
| $sha512 = (Get-FileHash -Path $exe.FullName -Algorithm SHA512).Hash.ToLower() | |
| $size = $exe.Length | |
| @" | |
| version: $version | |
| files: | |
| - url: $($exe.Name.Replace(' ', '.')) | |
| sha512: $sha512 | |
| size: $size | |
| path: $($exe.Name.Replace(' ', '.')) | |
| sha512: $sha512 | |
| "@ | Out-File -FilePath "staged/latest.yml" -Encoding utf8 | |
| # Rename exe to match (spaces to dots) | |
| $newName = $exe.Name.Replace(' ', '.') | |
| if ($exe.Name -ne $newName) { | |
| Rename-Item -Path $exe.FullName -NewName $newName | |
| } | |
| } | |
| - name: Generate latest-mac.yml for electron-updater (macOS) | |
| if: matrix.platform == 'macos' | |
| shell: bash | |
| run: | | |
| VERSION=$(jq -r '.version' package.json) | |
| ZIP_FILE=$(find staged -name "*.zip" | head -1) | |
| if [ -n "$ZIP_FILE" ]; then | |
| SHA512=$(shasum -a 512 "$ZIP_FILE" | awk '{print $1}') | |
| SIZE=$(stat -f%z "$ZIP_FILE") | |
| FILENAME=$(basename "$ZIP_FILE") | |
| cat > staged/latest-mac.yml << EOF | |
| version: $VERSION | |
| files: | |
| - url: $FILENAME | |
| sha512: $SHA512 | |
| size: $SIZE | |
| path: $FILENAME | |
| sha512: $SHA512 | |
| EOF | |
| fi | |
| - name: Generate latest-linux.yml for electron-updater (Linux) | |
| if: matrix.platform == 'linux' | |
| shell: bash | |
| run: | | |
| VERSION=$(jq -r '.version' package.json) | |
| # Prefer AppImage, fall back to deb | |
| FILE=$(find staged -name "*.AppImage" | head -1) | |
| [ -z "$FILE" ] && FILE=$(find staged -name "*.deb" | head -1) | |
| if [ -n "$FILE" ]; then | |
| SHA512=$(sha512sum "$FILE" | awk '{print $1}') | |
| SIZE=$(stat -c%s "$FILE") | |
| FILENAME=$(basename "$FILE") | |
| cat > staged/latest-linux.yml << EOF | |
| version: $VERSION | |
| files: | |
| - url: $FILENAME | |
| sha512: $SHA512 | |
| size: $SIZE | |
| path: $FILENAME | |
| sha512: $SHA512 | |
| EOF | |
| fi | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-${{ matrix.platform }} | |
| path: staged/* | |
| if-no-files-found: error | |
| release: | |
| needs: [check-version, build] | |
| if: needs.check-version.outputs.should_release == 'true' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Display downloaded files | |
| run: find artifacts -type f | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ needs.check-version.outputs.version }} | |
| name: Release v${{ needs.check-version.outputs.version }} | |
| generate_release_notes: true | |
| files: artifacts/**/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |