Skip to content

Create GitHub Releases on main #832

Create GitHub Releases on main

Create GitHub Releases on main #832

name: Create GitHub Releases on main
on:
workflow_dispatch:
push:
branches:
- main
workflow_run:
workflows:
- Update Google Antigravity packages
types:
- completed
permissions:
contents: write
jobs:
create-release:
if: github.event_name != 'workflow_run' || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main')
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- product_display_name: Antigravity IDE
package_dir: package
version_channel: ide
tag_prefix: antigravity-ide-v
- product_display_name: Antigravity 2.0
package_dir: package-2.0
version_channel: 2.0
tag_prefix: antigravity-2-0-v
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
ref: main
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y ca-certificates curl coreutils
- name: Detect latest upstream version
id: upstream
run: |
chmod +x ./scripts/check-antigravity-version.sh
OUTPUT=$(./scripts/check-antigravity-version.sh "${{ matrix.version_channel }}")
VERSION=$(echo "$OUTPUT" | cut -d' ' -f1 | tr -d '[:space:]')
if [ -z "$VERSION" ]; then
echo "Could not determine latest upstream version"
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Extract version from PKGBUILD
id: version
run: |
VERSION=$(grep '^pkgver=' "${{ matrix.package_dir }}/PKGBUILD" | cut -d'=' -f2 | tr -d '[:space:]')
if [ -z "$VERSION" ]; then
echo "Could not determine version from ${{ matrix.package_dir }}/PKGBUILD"
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=${{ matrix.tag_prefix }}$VERSION" >> "$GITHUB_OUTPUT"
- name: Check if main is on latest upstream version
id: freshness
run: |
CURRENT_VERSION="${{ steps.version.outputs.version }}"
LATEST_VERSION="${{ steps.upstream.outputs.version }}"
echo "Current version: $CURRENT_VERSION"
echo "Latest upstream version: $LATEST_VERSION"
if [ "$CURRENT_VERSION" = "$LATEST_VERSION" ]; then
echo "is_latest=true" >> "$GITHUB_OUTPUT"
else
echo "is_latest=false" >> "$GITHUB_OUTPUT"
fi
- name: Check if release already exists
id: release_exists
if: steps.freshness.outputs.is_latest == 'true'
uses: actions/github-script@v9
with:
script: |
const tag = '${{ steps.version.outputs.tag }}';
try {
await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag
});
core.setOutput('exists', 'true');
} catch (error) {
if (error.status === 404) {
core.setOutput('exists', 'false');
} else {
throw error;
}
}
- name: Determine target commit
id: target
if: steps.freshness.outputs.is_latest == 'true'
run: |
echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
- name: Skip release on stale main
if: steps.freshness.outputs.is_latest != 'true'
run: |
echo "${{ matrix.package_dir }}/PKGBUILD is behind upstream. Skipping release until main is updated."
- name: Create GitHub Release
if: steps.freshness.outputs.is_latest == 'true' && steps.release_exists.outputs.exists == 'false'
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ steps.version.outputs.tag }}
name: ${{ matrix.product_display_name }} v${{ steps.version.outputs.version }}
target_commitish: ${{ steps.target.outputs.sha }}
generate_release_notes: true
body: |
Automated ${{ matrix.product_display_name }} release created after merge/push to main.
Package version: `${{ steps.version.outputs.version }}`.
- name: Release already exists
if: steps.freshness.outputs.is_latest == 'true' && steps.release_exists.outputs.exists == 'true'
run: echo "Release ${{ steps.version.outputs.tag }} already exists. Skipping."