Skip to content

Check GitHub Release #1186

Check GitHub Release

Check GitHub Release #1186

name: Check GitHub Release
on:
schedule:
# Six times a day, every 4 hours at :20
- cron: '20 */6 * * *'
# Enables manually running this workflow from the Actions tab
workflow_dispatch:
jobs:
check:
name: Check GitHub Release
runs-on: ubuntu-slim
env:
BINARY_NAME: tuist
BINARY_REPO: tuist/tuist
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SEMANTIC_VERSIONING_REGEX: "^[v]?[0-9]+\\.[0-9]+\\.[0-9]+$"
steps:
- name: Check versions and trigger publish if needed
run: |
# Temp files for capturing parallel command output
PLUGIN_FILE=$(mktemp)
BINARY_FILE=$(mktemp)
# Fetch latest semver release from both repos in parallel
gh release list -R ${{ github.repository }} -L 10 --json tagName,publishedAt | \
jq -r --arg re "$SEMANTIC_VERSIONING_REGEX" 'map(select(.tagName | test($re))) | sort_by(.publishedAt) | reverse | .[0].tagName' \
> "$PLUGIN_FILE" &
plugin_pid=$!
gh release list -R ${{ env.BINARY_REPO }} -L 10 --json tagName,publishedAt | \
jq -r --arg re "$SEMANTIC_VERSIONING_REGEX" 'map(select(.tagName | test($re))) | sort_by(.publishedAt) | reverse | .[0].tagName' \
> "$BINARY_FILE" &
binary_pid=$!
# Wait for both fetches; exits non-zero if either fails
wait $plugin_pid
wait $binary_pid
PLUGIN_VERSION=$(cat "$PLUGIN_FILE")
BINARY_VERSION=$(cat "$BINARY_FILE")
# Trigger publish workflow only when upstream has a newer release
if [[ "$PLUGIN_VERSION" != "$BINARY_VERSION" ]]; then
gh workflow run .github/workflows/publish-artifact-bundle.yml \
-R ${{ github.repository }} \
--ref "$GITHUB_REF_NAME" \
--field binary_name="${{ env.BINARY_NAME }}" \
--field binary_repo="${{ env.BINARY_REPO }}" \
--field binary_version="$BINARY_VERSION" \
--field plugin_repo="${{ github.repository }}"
fi