Files
OpenBB/.github/workflows/release-desktop.yml
2025-10-17 08:36:18 -07:00

291 lines
10 KiB
YAML
Vendored

name: Release ODP Desktop
on:
workflow_call:
inputs:
draft:
required: true
type: boolean
release:
types: [published]
workflow_dispatch:
inputs:
draft:
description: "Create as draft release"
required: false
default: "false"
jobs:
build-windows:
uses: ./.github/workflows/build-desktop-win64.yml
with:
release: true
secrets: inherit
permissions:
contents: write
build-macos-arm:
uses: ./.github/workflows/build-desktop-osxARM.yml
with:
release: true
secrets: inherit
permissions:
contents: write
build-macos-x64:
uses: ./.github/workflows/build-desktop-osx64.yml
with:
release: true
secrets: inherit
permissions:
contents: write
publish:
needs: [build-windows, build-macos-arm, build-macos-x64]
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.extract_version.outputs.version }}
versioned_tag: ${{ steps.extract_version.outputs.versioned_tag }}
release_name: ${{ steps.extract_version.outputs.release_name }}
is_draft: ${{ github.event.inputs.draft == 'true' || github.event.inputs.draft == true || inputs.draft == true }}
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Sanitize artifact filenames
run: |
find ./artifacts -depth -name "* *" | while read -r file; do mv "$file" "$(echo "$file" | tr ' ' '-')"; done
- name: Extract Version and Tag
id: extract_version
run: |
INSTALLER_FILE=$(find ./artifacts -name "*.exe" -o -name "*.dmg" | head -n 1)
if [ -z "$INSTALLER_FILE" ]; then
echo "::error::No installer file found in artifacts."
exit 1
fi
VERSION=$(basename "$INSTALLER_FILE" | sed -n 's/.*_\([0-9]\+\.[0-9]\+\.[0-9]\+\)_.*/\1/p')
if [ -z "$VERSION" ]; then
echo "::error::Could not extract version from filename: $(basename "$INSTALLER_FILE")"
exit 1
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "release_name=Open Data Platform v$VERSION" >> $GITHUB_OUTPUT
echo "versioned_tag=Open-Data-Platform-v$VERSION" >> $GITHUB_OUTPUT
- name: Prepare assets and generate release.json for VERSIONED release
id: prep_assets
run: |
mkdir ./release_assets
find ./artifacts -type f -print -exec cp {} ./release_assets/ \;
cd ./release_assets
VERSION="${{ steps.extract_version.outputs.version }}"
RELEASE_NAME="${{ steps.extract_version.outputs.release_name }}"
VERSIONED_TAG="${{ steps.extract_version.outputs.versioned_tag }}"
cat << EOF > release.json
{
"version": "$VERSION",
"notes": "Release for $RELEASE_NAME",
"pub_date": "$(date -u +'%Y-%m-%dT%H:%M:%SZ')",
"platforms": {
EOF
FIRST_PLATFORM=true
WIN_EXE=$(find . -name "*_x86_64.exe" | head -n 1)
if [ -n "$WIN_EXE" ]; then
WIN_SIG_FILE="${WIN_EXE}.sig"
WIN_SIG=$(cat "$WIN_SIG_FILE")
WIN_URL="https://github.com/${{ github.repository }}/releases/download/${VERSIONED_TAG}/$(basename "$WIN_EXE")"
cat << EOF >> release.json
"windows-x86_64": {
"signature": "$WIN_SIG",
"url": "$WIN_URL"
}
EOF
FIRST_PLATFORM=false
fi
MAC_ARM_TAR=$(find . -name "*_aarch64.app.tar.gz" | head -n 1)
if [ -n "$MAC_ARM_TAR" ]; then
if [ "$FIRST_PLATFORM" = false ]; then
echo "," >> release.json
fi
MAC_ARM_SIG=$(cat "${MAC_ARM_TAR}.sig")
MAC_ARM_URL="https://github.com/${{ github.repository }}/releases/download/${VERSIONED_TAG}/$(basename "$MAC_ARM_TAR")"
cat << EOF >> release.json
"darwin-aarch64": {
"signature": "$MAC_ARM_SIG",
"url": "$MAC_ARM_URL"
}
EOF
FIRST_PLATFORM=false
fi
MAC_X64_TAR=$(find . -name "*_x86_64.app.tar.gz" | head -n 1)
if [ -n "$MAC_X64_TAR" ]; then
if [ "$FIRST_PLATFORM" = false ]; then
echo "," >> release.json
fi
MAC_X64_SIG=$(cat "${MAC_X64_TAR}.sig")
MAC_X64_URL="https://github.com/${{ github.repository }}/releases/download/${VERSIONED_TAG}/$(basename "$MAC_X64_TAR")"
cat << EOF >> release.json
"darwin-x86_64": {
"signature": "$MAC_X64_SIG",
"url": "$MAC_X64_URL"
}
EOF
fi
cat << EOF >> release.json
}
}
EOF
echo "Generated release.json for VERSIONED release:"
cat release.json
cd ..
echo "assets_path=./release_assets" >> $GITHUB_OUTPUT
- name: Create VERSIONED release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.extract_version.outputs.versioned_tag }}
name: ${{ steps.extract_version.outputs.release_name }}
files: ${{ steps.prep_assets.outputs.assets_path }}/*
draft: ${{ github.event.inputs.draft == 'true' || github.event.inputs.draft == true || inputs.draft == true }}
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}
update-odp-release:
needs: publish
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download release artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Delete existing ODP tag and release
continue-on-error: true
run: |
gh release delete ODP --yes || true
git push origin :refs/tags/ODP || true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare ODP assets and generate latest.json for ODP release
run: |
mkdir ./odp_assets
# Copy and rename installer files - replace version with "latest"
for file in $(find ./artifacts -name "*.exe"); do
BASENAME=$(basename "$file")
NEW_NAME=$(echo "$BASENAME" | sed -E 's/_[0-9]+\.[0-9]+\.[0-9]+_/_latest_/')
cp "$file" "./odp_assets/$NEW_NAME"
done
for file in $(find ./artifacts -name "*.dmg"); do
BASENAME=$(basename "$file")
NEW_NAME=$(echo "$BASENAME" | sed -E 's/_[0-9]+\.[0-9]+\.[0-9]+_/_latest_/')
cp "$file" "./odp_assets/$NEW_NAME"
done
VERSION="${{ needs.publish.outputs.version }}"
RELEASE_NAME="${{ needs.publish.outputs.release_name }}"
VERSIONED_TAG="${{ needs.publish.outputs.versioned_tag }}"
cd ./odp_assets
cat << EOF > latest.json
{
"version": "$VERSION",
"notes": "Latest stable release - $RELEASE_NAME",
"pub_date": "$(date -u +'%Y-%m-%dT%H:%M:%SZ')",
"platforms": {
EOF
FIRST_PLATFORM=true
# JSON points to ORIGINAL files in VERSIONED release
WIN_EXE=$(find ../artifacts -name "*_x86_64.exe" | head -n 1)
if [ -n "$WIN_EXE" ]; then
WIN_SIG_FILE="${WIN_EXE}.sig"
WIN_SIG=$(cat "$WIN_SIG_FILE")
WIN_URL="https://github.com/${{ github.repository }}/releases/download/${VERSIONED_TAG}/$(basename "$WIN_EXE")"
cat << EOF >> latest.json
"windows-x86_64": {
"signature": "$WIN_SIG",
"url": "$WIN_URL"
}
EOF
FIRST_PLATFORM=false
fi
MAC_ARM_TAR=$(find ../artifacts -name "*_aarch64.app.tar.gz" | head -n 1)
if [ -n "$MAC_ARM_TAR" ]; then
if [ "$FIRST_PLATFORM" = false ]; then
echo "," >> latest.json
fi
MAC_ARM_SIG=$(cat "${MAC_ARM_TAR}.sig")
MAC_ARM_URL="https://github.com/${{ github.repository }}/releases/download/${VERSIONED_TAG}/$(basename "$MAC_ARM_TAR")"
cat << EOF >> latest.json
"darwin-aarch64": {
"signature": "$MAC_ARM_SIG",
"url": "$MAC_ARM_URL"
}
EOF
FIRST_PLATFORM=false
fi
MAC_X64_TAR=$(find ../artifacts -name "*_x86_64.app.tar.gz" | head -n 1)
if [ -n "$MAC_X64_TAR" ]; then
if [ "$FIRST_PLATFORM" = false ]; then
echo "," >> latest.json
fi
MAC_X64_SIG=$(cat "${MAC_X64_TAR}.sig")
MAC_X64_URL="https://github.com/${{ github.repository }}/releases/download/${VERSIONED_TAG}/$(basename "$MAC_X64_TAR")"
cat << EOF >> latest.json
"darwin-x86_64": {
"signature": "$MAC_X64_SIG",
"url": "$MAC_X64_URL"
}
EOF
fi
cat << EOF >> latest.json
}
}
EOF
echo "Generated latest.json for ODP release:"
cat latest.json
- name: Create ODP release
uses: softprops/action-gh-release@v1
with:
tag_name: ODP
name: ODP Desktop (Latest Stable)
body: |
**This is the latest stable release (v${{ needs.publish.outputs.version }})**
This release always points to the most recent stable version.
For version-specific details and release notes, see: [${{ needs.publish.outputs.release_name }}](https://github.com/${{ github.repository }}/releases/tag/${{ needs.publish.outputs.versioned_tag }})
The `latest.json` file in this release is used by the auto-updater to check for new versions.
files: ./odp_assets/*
prerelease: false
draft: ${{ needs.publish.outputs.is_draft == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}