Support Airflow 3 monitoring DAG on Hybrid (#2207) #32
Workflow file for this run
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: | |
| tags: | |
| - 'v[0-9]+.[0-9]+.[0-9]+' | |
| - 'v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+' | |
| - 'v[0-9]+.[0-9]+.[0-9]+-nightly.[0-9]*' | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| id-token: write # Required for Octo STS OIDC token exchange | |
| jobs: | |
| detect: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| type: ${{ steps.parse.outputs.type }} | |
| version: ${{ steps.parse.outputs.version }} | |
| tag: ${{ steps.parse.outputs.tag }} | |
| steps: | |
| - name: Parse tag | |
| id: parse | |
| run: | | |
| TAG="${GITHUB_REF_NAME}" | |
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" | |
| if [[ "$TAG" =~ -nightly\. ]]; then | |
| TYPE="nightly" | |
| VERSION="${TAG#v}" | |
| elif [[ "$TAG" =~ -rc\. ]]; then | |
| TYPE="rc" | |
| VERSION="${TAG#v}" | |
| VERSION="${VERSION%-rc.*}" | |
| else | |
| TYPE="ga" | |
| VERSION="${TAG#v}" | |
| fi | |
| echo "type=$TYPE" >> "$GITHUB_OUTPUT" | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "Parsed — Tag: $TAG | Type: $TYPE | Version: $VERSION" | |
| release: | |
| needs: detect | |
| runs-on: macos-15 | |
| timeout-minutes: 30 | |
| steps: | |
| - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Resolve source commit | |
| id: source | |
| run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" | |
| - uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5 | |
| id: setup-go | |
| with: | |
| go-version-file: go.mod | |
| cache: false | |
| - name: Cache Go build outputs | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 | |
| with: | |
| path: ~/Library/Caches/go-build | |
| key: release-go-build-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.sum') }}-${{ steps.source.outputs.sha }} | |
| restore-keys: | | |
| release-go-build-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('go.sum') }}- | |
| - name: Find previous GA tag for changelog | |
| id: prev-tag | |
| run: | | |
| # Find the latest GA tag (excluding the current tag and any prereleases). | |
| # All release types (nightly/RC/GA) compare against the last GA for changelog continuity. | |
| PREV_GA=$(git tag -l "v[0-9]*.[0-9]*.[0-9]*" \ | |
| | grep -v -- '-' \ | |
| | grep -v "^${{ needs.detect.outputs.tag }}$" \ | |
| | sed 's/^v//' \ | |
| | sort -t. -k1,1n -k2,2n -k3,3n \ | |
| | tail -1 \ | |
| | sed 's/^/v/') | |
| echo "tag=$PREV_GA" >> "$GITHUB_OUTPUT" | |
| echo "Previous GA tag for changelog: $PREV_GA" | |
| - name: Get Homebrew token via Octo STS | |
| if: needs.detect.outputs.type == 'ga' | |
| uses: octo-sts/action@f603d3be9d8dd9871a265776e625a27b00effe05 # v1.1.1 | |
| id: homebrew-token | |
| with: | |
| scope: astronomer | |
| identity: astro-cli-homebrew | |
| - uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6 | |
| with: | |
| version: v2.15.2 | |
| args: release --clean | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| HOMEBREW_TAP_TOKEN: ${{ steps.homebrew-token.outputs.token }} | |
| GORELEASER_CURRENT_TAG: ${{ needs.detect.outputs.tag }} | |
| GORELEASER_PREVIOUS_TAG: ${{ steps.prev-tag.outputs.tag }} | |
| update-godownloader: | |
| needs: [detect, release] | |
| if: always() && !cancelled() && needs.detect.outputs.type == 'ga' && needs.release.result != 'skipped' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Verify GitHub release exists | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG="${{ needs.detect.outputs.tag }}" | |
| if ! gh release view "$TAG" --repo "${{ github.repository }}" >/dev/null 2>&1; then | |
| echo "::error::GitHub release $TAG does not exist. Skipping godownloader update." | |
| exit 1 | |
| fi | |
| echo "Release $TAG confirmed." | |
| - name: Get token via Octo STS | |
| uses: octo-sts/action@f603d3be9d8dd9871a265776e625a27b00effe05 # v1.1.1 | |
| id: godownloader-token | |
| with: | |
| scope: astronomer | |
| identity: astro-cli-release | |
| - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| with: | |
| ref: main | |
| token: ${{ steps.godownloader-token.outputs.token }} | |
| - name: Update LATEST_VERSION in godownloader.sh | |
| run: | | |
| TAG="v${{ needs.detect.outputs.version }}" | |
| sed -i "s/^LATEST_VERSION=.*/LATEST_VERSION=${TAG}/" godownloader.sh | |
| - name: Create PR | |
| env: | |
| GH_TOKEN: ${{ steps.godownloader-token.outputs.token }} | |
| run: | | |
| TAG="v${{ needs.detect.outputs.version }}" | |
| BRANCH="chore/update-godownloader-${TAG}" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git checkout -b "${BRANCH}" | |
| git add godownloader.sh | |
| git commit -m "chore: update godownloader to ${TAG}" | |
| git push origin "${BRANCH}" | |
| PR_BODY="Automated PR to update \`LATEST_VERSION\` in \`godownloader.sh\` to \`${TAG}\`." | |
| PR_BODY+=$'\n\n'"Triggered by release [${TAG}](https://github.com/${{ github.repository }}/releases/tag/${TAG})." | |
| gh pr create \ | |
| --base main \ | |
| --title "CLI Release: update godownloader to ${TAG}" \ | |
| --body "$PR_BODY" | |
| update-winget: | |
| needs: [detect, release] | |
| if: always() && !cancelled() && needs.detect.outputs.type == 'ga' && needs.release.result != 'skipped' | |
| runs-on: windows-latest | |
| steps: | |
| - name: Verify GitHub release exists | |
| shell: bash | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG="${{ needs.detect.outputs.tag }}" | |
| if ! gh release view "$TAG" --repo "${{ github.repository }}" >/dev/null 2>&1; then | |
| echo "::error::GitHub release $TAG does not exist. Skipping winget update." | |
| exit 1 | |
| fi | |
| echo "Release $TAG confirmed." | |
| - name: Get Winget token via Octo STS | |
| uses: octo-sts/action@f603d3be9d8dd9871a265776e625a27b00effe05 # v1.1.1 | |
| id: winget-token | |
| with: | |
| scope: astronomer | |
| identity: astro-cli-winget | |
| - uses: vedantmgoyal9/winget-releaser@4ffc7888bffd451b357355dc214d43bb9f23917e # v2 | |
| with: | |
| identifier: Astronomer.Astro | |
| version: ${{ needs.detect.outputs.version }} | |
| release-tag: ${{ needs.detect.outputs.tag }} | |
| installers-regex: '\.exe$' | |
| token: ${{ steps.winget-token.outputs.token }} | |
| cleanup-nightlies: | |
| needs: [detect, release] | |
| if: needs.detect.outputs.type == 'nightly' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Delete old nightly releases and tags | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -e | |
| KEEP=5 | |
| # List all nightly releases sorted by creation date (newest first) | |
| NIGHTLY_TAGS=$(gh release list \ | |
| --repo "${{ github.repository }}" \ | |
| --limit 100 \ | |
| --json tagName,createdAt \ | |
| --jq '[.[] | select(.tagName | test("-nightly\\.")) ] | sort_by(.createdAt) | reverse | .[].tagName') | |
| COUNT=0 | |
| for TAG in $NIGHTLY_TAGS; do | |
| COUNT=$((COUNT + 1)) | |
| if [ "$COUNT" -le "$KEEP" ]; then | |
| echo "Keeping: $TAG" | |
| continue | |
| fi | |
| echo "Deleting release and tag: $TAG" | |
| gh release delete "$TAG" --repo "${{ github.repository }}" --yes --cleanup-tag | |
| done | |
| echo "Nightly cleanup complete. Kept $KEEP most recent, deleted $((COUNT - KEEP > 0 ? COUNT - KEEP : 0)) old nightlies." | |
| notify: | |
| needs: [detect, release, update-godownloader, update-winget] | |
| if: always() && !cancelled() && needs.detect.outputs.type == 'ga' && needs.release.result != 'skipped' | |
| runs-on: ubuntu-latest | |
| env: | |
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| steps: | |
| - name: Verify GitHub release exists | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG="${{ needs.detect.outputs.tag }}" | |
| if ! gh release view "$TAG" --repo "${{ github.repository }}" >/dev/null 2>&1; then | |
| echo "::error::GitHub release $TAG does not exist. Skipping notification." | |
| exit 1 | |
| fi | |
| echo "Release $TAG confirmed." | |
| - name: Post release summary | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG="v${{ needs.detect.outputs.version }}" | |
| RELEASE_STATUS="${{ needs.release.result }}" | |
| GODOWNLOADER_STATUS="${{ needs.update-godownloader.result }}" | |
| WINGET_STATUS="${{ needs.update-winget.result }}" | |
| SUMMARY="## Post-Release Automation Summary"$'\n\n' | |
| SUMMARY+="| Task | Status |"$'\n' | |
| SUMMARY+="|------|--------|"$'\n' | |
| SUMMARY+="| GoReleaser (binaries + Homebrew PR) | ${RELEASE_STATUS} |"$'\n' | |
| SUMMARY+="| Godownloader PR | ${GODOWNLOADER_STATUS} |"$'\n' | |
| SUMMARY+="| Winget PR | ${WINGET_STATUS} |" | |
| # Get the release ID by tag, then append the summary to the release body | |
| RELEASE_ID=$(gh api "/repos/${{ github.repository }}/releases/tags/${TAG}" --jq '.id' 2>/dev/null) || true | |
| if [ -n "$RELEASE_ID" ]; then | |
| EXISTING_BODY=$(gh api "/repos/${{ github.repository }}/releases/${RELEASE_ID}" --jq '.body // ""') | |
| UPDATED_BODY="${EXISTING_BODY}"$'\n\n'"${SUMMARY}" | |
| gh api \ | |
| --method PATCH \ | |
| "/repos/${{ github.repository }}/releases/${RELEASE_ID}" \ | |
| -f body="${UPDATED_BODY}" || true | |
| fi | |
| - name: Notify Slack | |
| if: env.SLACK_WEBHOOK_URL != '' | |
| run: | | |
| TAG="v${{ needs.detect.outputs.version }}" | |
| curl -s -X POST "$SLACK_WEBHOOK_URL" \ | |
| -H 'Content-type: application/json' \ | |
| -d "{\"text\":\"Astro CLI ${TAG} has been released: https://github.com/${{ github.repository }}/releases/tag/${TAG}\"}" |