Release patch
#406
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" | |
| run-name: "Release `${{ inputs.bump_type }}`" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| bump_type: | |
| description: 'Version bump type' | |
| required: true | |
| type: choice | |
| default: patch | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| trigger_deploy_after_release: | |
| description: 'Trigger deploy after release' | |
| required: true | |
| type: boolean | |
| default: true | |
| environment: | |
| description: 'Environment to deploy to' | |
| required: true | |
| type: choice | |
| default: prod | |
| options: | |
| - dev | |
| - prod | |
| workflow_call: | |
| inputs: | |
| bump_type: | |
| description: "Version bump type" | |
| required: false | |
| type: string | |
| default: patch | |
| trigger_deploy_after_release: | |
| description: "Trigger deploy after release" | |
| required: false | |
| type: boolean | |
| default: true | |
| environment: | |
| description: "Environment to deploy to" | |
| required: false | |
| type: string | |
| default: prod | |
| outputs: | |
| version: | |
| description: "Released version" | |
| value: ${{ jobs.prereq.outputs.version }} | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: helium-platform-release | |
| jobs: | |
| prereq: | |
| uses: HeliumEdu/.github/.github/workflows/release-prereq.yml@main | |
| with: | |
| bump_type: ${{ inputs.bump_type }} | |
| version_format: python | |
| version_file: conf/configs/common.py | |
| repo_slug: HeliumEdu/platform | |
| secrets: | |
| bot_app_id: ${{ secrets.HELIUM_BOT_APP_ID }} | |
| bot_private_key: ${{ secrets.HELIUM_BOT_PRIVATE_KEY }} | |
| test: | |
| name: Test | |
| needs: [prereq] | |
| runs-on: ubuntu-latest | |
| env: | |
| FORCE_COLOR: 1 | |
| PYTHONUNBUFFERED: 1 | |
| PYTHONDONTWRITEBYTECODE: 1 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ needs.prereq.outputs.squash_commit_sha }} | |
| - name: Set up Python "3.12" | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.12" | |
| - name: Test | |
| run: make test | |
| build-and-publish: | |
| name: Build and Publish AMD64 Containers | |
| needs: [prereq, test] | |
| if: "!cancelled() && needs.prereq.result == 'success' && needs.test.result == 'success'" | |
| runs-on: ubuntu-24.04 | |
| env: | |
| FORCE_COLOR: 1 | |
| PYTHONUNBUFFERED: 1 | |
| PYTHONDONTWRITEBYTECODE: 1 | |
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| PLATFORM: amd64 | |
| TAG_VERSION: ${{ needs.prereq.outputs.version }} | |
| ENVIRONMENT: prod | |
| ANALYTICS_ENABLED: 1 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ needs.prereq.outputs.squash_commit_sha }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v4 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Login to AWS ECR Public | |
| run: | | |
| aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/heliumedu | |
| - name: Build and smoke test containers | |
| run: make docker-env build-docker smoke-test-docker | |
| - name: Publish containers | |
| run: make publish | |
| - name: Dump Docker logs on failure | |
| if: failure() | |
| uses: jwalton/gh-docker-logs@v2 | |
| build-and-publish-arm64: | |
| name: Build and Publish ARM64 Containers | |
| needs: [prereq, test] | |
| if: "!cancelled() && needs.prereq.result == 'success' && needs.test.result == 'success'" | |
| runs-on: ubuntu-24.04-arm | |
| env: | |
| FORCE_COLOR: 1 | |
| PYTHONUNBUFFERED: 1 | |
| PYTHONDONTWRITEBYTECODE: 1 | |
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| PLATFORM: arm64 | |
| TAG_VERSION: ${{ needs.prereq.outputs.version }} | |
| ENVIRONMENT: prod | |
| ANALYTICS_ENABLED: 1 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ needs.prereq.outputs.squash_commit_sha }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v4 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Login to AWS ECR Public | |
| run: | | |
| aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/heliumedu | |
| - name: Build and smoke test containers | |
| run: make docker-env build-docker smoke-test-docker | |
| - name: Publish containers | |
| run: make publish | |
| - name: Dump Docker logs on failure | |
| if: failure() | |
| uses: jwalton/gh-docker-logs@v2 | |
| create-release-tag: | |
| name: Create Release Tag | |
| needs: [prereq, build-and-publish, build-and-publish-arm64] | |
| if: "!cancelled() && needs.prereq.result == 'success' && needs['build-and-publish'].result == 'success' && needs['build-and-publish-arm64'].result == 'success'" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Generate GitHub App token | |
| id: app-token | |
| uses: actions/create-github-app-token@v3 | |
| with: | |
| client-id: ${{ secrets.HELIUM_BOT_APP_ID }} | |
| private-key: ${{ secrets.HELIUM_BOT_PRIVATE_KEY }} | |
| skip-token-revoke: true | |
| - uses: actions/checkout@v6 | |
| with: | |
| token: ${{ steps.app-token.outputs.token }} | |
| ref: ${{ needs.prereq.outputs.squash_commit_sha }} | |
| fetch-depth: 0 | |
| - name: Get GitHub App bot user ID | |
| id: get-bot-user-id | |
| env: | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| run: | | |
| echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT" | |
| - name: Create and push tag | |
| env: | |
| VERSION: ${{ needs.prereq.outputs.version }} | |
| COMMIT_SHA: ${{ needs.prereq.outputs.squash_commit_sha }} | |
| run: | | |
| git config --global user.name "${{ steps.app-token.outputs.app-slug }}[bot]" | |
| git config --global user.email "${{ steps.get-bot-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com" | |
| if git rev-parse "$VERSION" >/dev/null 2>&1; then | |
| echo "Tag $VERSION already exists, skipping" | |
| else | |
| echo "Creating tag $VERSION on commit $COMMIT_SHA" | |
| git tag -a "$VERSION" -m "Release $VERSION" "$COMMIT_SHA" | |
| git push origin "$VERSION" | |
| fi | |
| - name: Create Sentry release | |
| env: | |
| SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
| VERSION: ${{ needs.prereq.outputs.version }} | |
| run: | | |
| pip install sentry-cli==3.6.2 | |
| SENTRY_PROPERTIES=sentry.properties sentry-cli releases new "$VERSION" | |
| SENTRY_PROPERTIES=sentry.properties sentry-cli releases set-commits --auto "$VERSION" | |
| SENTRY_PROPERTIES=sentry.properties sentry-cli releases finalize "$VERSION" | |
| deploy: | |
| name: Trigger Deploy Workflow | |
| needs: [prereq, create-release-tag] | |
| if: "!cancelled() && (inputs.trigger_deploy_after_release == true || inputs.trigger_deploy_after_release == 'true') && needs.prereq.result == 'success' && needs['create-release-tag'].result == 'success'" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Generate GitHub App token | |
| id: app-token | |
| uses: actions/create-github-app-token@v3 | |
| with: | |
| client-id: ${{ secrets.HELIUM_BOT_APP_ID }} | |
| private-key: ${{ secrets.HELIUM_BOT_PRIVATE_KEY }} | |
| skip-token-revoke: true | |
| - name: Trigger deploy workflow | |
| env: | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| VERSION: ${{ needs.prereq.outputs.version }} | |
| ENVIRONMENT: ${{ inputs.environment }} | |
| run: | | |
| gh workflow run deploy.yml \ | |
| --repo ${{ github.repository }} \ | |
| -f version_type=specific \ | |
| -f specific_version="$VERSION" \ | |
| -f environment="$ENVIRONMENT" | |
| - name: Deployment trigger summary | |
| env: | |
| VERSION: ${{ needs.prereq.outputs.version }} | |
| ENVIRONMENT: ${{ inputs.environment }} | |
| run: | | |
| echo "### Deploy Workflow Triggered" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Version**: $VERSION" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Environment**: $ENVIRONMENT" >> $GITHUB_STEP_SUMMARY | |
| cleanup: | |
| needs: [prereq, deploy] | |
| if: always() && needs.prereq.result == 'success' | |
| uses: HeliumEdu/.github/.github/workflows/release-cleanup.yml@main | |
| secrets: | |
| bot_app_id: ${{ secrets.HELIUM_BOT_APP_ID }} | |
| bot_private_key: ${{ secrets.HELIUM_BOT_PRIVATE_KEY }} |