release.yaml•8.69 kB
name: release
on:
push:
branches:
- main
paths:
- mods/**
- package.json
- package-lock.json
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
outputs:
RELEASE: ${{ env.RELEASE }}
LERNA_VERSION: ${{ env.LERNA_VERSION }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_PAT }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22.x"
- name: Install dependencies and build
run: |
npm install
npm run build
# We will do this manually for now
- name: Check for next release
run: |
release=$(.scripts/next-release.sh)
echo "Next release: $release"
echo "RELEASE=$release" >> $GITHUB_ENV
- name: Publish packages to NPM
if: env.RELEASE != 'none'
run: |
echo "NPM_TOKEN=${{ secrets.NPM_TOKEN }}" >> $GITHUB_ENV
echo "GITHUB_TOKEN=${{ secrets.GH_PAT }}" >> $GITHUB_ENV
echo "@routr:registry=https://registry.npmjs.org/" > .npmrc
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> .npmrc
git config --global user.name "GitHub Actions Bot"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git checkout .
# FIXME: This is a workaround to prevent the unit tests from failing
cp .env.example.dev .env
sed -i "s|AUTOPILOT_INTEGRATIONS_FILE=.*|AUTOPILOT_INTEGRATIONS_FILE=./config/integrations.example.json|g" .env
npm run release
- name: Get version from Lerna
run: |
lerna_version=$(node -p "require('./lerna.json').version")
echo "LERNA_VERSION=$lerna_version" >> $GITHUB_ENV
- name: Create release note
if: env.RELEASE != 'none'
id: changelog
uses: loopwerk/tag-changelog@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
exclude_types: other,doc,chore
config_file: ./.scripts/tag-changelog-config.cjs
- name: Create draft release
if: env.RELEASE != 'none'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.LERNA_VERSION }}
release_name: Release v${{ env.LERNA_VERSION }}
body: ${{ steps.changelog.outputs.changelog }}
draft: true
publish-apiserver:
name: Publish APIServer to Docker Hub
needs: [build]
if: needs.build.outputs.RELEASE != 'none'
uses: ./.github/workflows/publish-apiserver.yaml
with:
version: ${{ needs.build.outputs.LERNA_VERSION }}
secrets: inherit
publish-autopilot:
name: Publish Autopilot to Docker Hub
needs: [build]
if: needs.build.outputs.RELEASE != 'none'
uses: ./.github/workflows/publish-autopilot.yaml
with:
version: ${{ needs.build.outputs.LERNA_VERSION }}
secrets: inherit
publish-dashboard:
name: Publish Dashboard to Docker Hub
needs: [build]
if: needs.build.outputs.RELEASE != 'none'
uses: ./.github/workflows/publish-dashboard.yaml
with:
version: ${{ needs.build.outputs.LERNA_VERSION }}
secrets: inherit
manual-approval:
name: Manual Approval for Release Finalization
needs: [build, publish-apiserver, publish-autopilot, publish-dashboard]
if: needs.build.outputs.RELEASE != 'none'
runs-on: ubuntu-latest
environment: release-approval
steps:
- name: Display release information
run: |
echo "✅ All Docker images have been built and published successfully!"
echo "📦 Version: ${{ needs.build.outputs.LERNA_VERSION }}"
echo "🐳 Docker images published:"
echo " - fonoster/apiserver:${{ needs.build.outputs.LERNA_VERSION }}"
echo " - fonoster/autopilot:${{ needs.build.outputs.LERNA_VERSION }}"
echo " - fonoster/dashboard:${{ needs.build.outputs.LERNA_VERSION }}"
echo ""
echo "Please review the draft release and Docker images."
echo "If everything looks good, approve this step to finalize the release."
- name: Wait for manual approval
uses: trstringer/manual-approval@v1
with:
secret: ${{ github.TOKEN }}
approvers: ${{ github.actor }}
minimum-approvals: 1
issue-title: "Release Approval Required - v${{ needs.build.outputs.LERNA_VERSION }}"
issue-body: |
## 🚀 Release Approval Required
**Version:** ${{ needs.build.outputs.LERNA_VERSION }}
### Docker Images Published:
- fonoster/apiserver:${{ needs.build.outputs.LERNA_VERSION }}
- fonoster/autopilot:${{ needs.build.outputs.LERNA_VERSION }}
- fonoster/dashboard:${{ needs.build.outputs.LERNA_VERSION }}
### Next Steps:
1. Review the draft release on GitHub
2. Verify Docker images are available
3. Approve this workflow to finalize the release
**Note:** This approval will publish the release and update the compose.yaml file.
exclude-workflow-initiator-as-approver: false
finalize-release:
name: Finalize Release and Update Compose
needs: [build, manual-approval]
if: needs.build.outputs.RELEASE != 'none'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_PAT }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22.x"
- name: Get version from Lerna
run: |
lerna_version=$(node -p "require('./lerna.json').version")
echo "LERNA_VERSION=$lerna_version" >> $GITHUB_ENV
- name: Find and publish release
run: |
# Get the release by tag
release_response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases/tags/v${{ env.LERNA_VERSION }}")
release_id=$(echo "$release_response" | jq -r '.id')
if [ "$release_id" = "null" ] || [ -z "$release_id" ]; then
echo "Error: Could not find release with tag v${{ env.LERNA_VERSION }}"
exit 1
fi
echo "Found release ID: $release_id"
# Publish the release (remove draft status)
curl -X PATCH \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/releases/$release_id" \
-d '{"draft": false}'
echo "✅ Release v${{ env.LERNA_VERSION }} has been published"
- name: Update compose.yaml with new version tags
run: |
# Update custom service images from any version to :${LERNA_VERSION}
sed -i "s|fonoster/dashboard:[^[:space:]]*|fonoster/dashboard:${{ env.LERNA_VERSION }}|g" compose.yaml
sed -i "s|fonoster/apiserver:[^[:space:]]*|fonoster/apiserver:${{ env.LERNA_VERSION }}|g" compose.yaml
sed -i "s|fonoster/autopilot:[^[:space:]]*|fonoster/autopilot:${{ env.LERNA_VERSION }}|g" compose.yaml
- name: Commit and push updated compose.yaml
run: |
git config --global user.name "GitHub Actions Bot"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add compose.yaml
# Check if there are any changes to commit
if git diff --staged --quiet; then
echo "No changes to commit - compose.yaml already up to date"
else
git commit -m "chore: update compose.yaml with version ${{ env.LERNA_VERSION }} [skip ci]"
git push origin main
echo "✅ Updated compose.yaml with version ${{ env.LERNA_VERSION }}"
fi
- name: Release Summary
run: |
echo "## 🎉 Release Finalization Complete!"
echo ""
echo "**Version:** ${{ env.LERNA_VERSION }}"
echo "**Status:** ✅ Published to GitHub"
echo "**Docker Images:** ✅ Available with tag ${{ env.LERNA_VERSION }}"
echo "**Compose File:** ✅ Updated with new version tags"
echo ""
echo "The release is now live and ready for use! 🚀"