feat(release): publish gitea release notes and enable production rollback
This commit is contained in:
@@ -8,7 +8,7 @@ on:
|
||||
inputs:
|
||||
release_tag:
|
||||
description: "Release tag in vX.Y.Z format"
|
||||
required: true
|
||||
required: false
|
||||
rollback_image_tag:
|
||||
description: "Optional rollback image tag"
|
||||
required: false
|
||||
@@ -21,6 +21,7 @@ env:
|
||||
jobs:
|
||||
release:
|
||||
name: Build Push Changelog
|
||||
if: github.event_name == 'push' || github.event.inputs.rollback_image_tag == ''
|
||||
runs-on: node22-bun
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -38,6 +39,10 @@ jobs:
|
||||
id: tag
|
||||
run: |
|
||||
if [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ]; then
|
||||
if [ -z "${{ github.event.inputs.release_tag }}" ]; then
|
||||
echo "release_tag input is required when publishing a release manually."
|
||||
exit 1
|
||||
fi
|
||||
echo "value=${{ github.event.inputs.release_tag }}" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "value=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
|
||||
@@ -49,6 +54,13 @@ jobs:
|
||||
- name: Generate changelog
|
||||
run: bun run changelog:release
|
||||
|
||||
- name: Build release notes payload
|
||||
run: |
|
||||
if ! sh .gitea/scripts/extract-release-notes.sh "${{ steps.tag.outputs.value }}" > .gitea-release-notes.md; then
|
||||
echo "Could not isolate section for tag ${{ steps.tag.outputs.value }}. Falling back to full CHANGELOG.md."
|
||||
cp CHANGELOG.md .gitea-release-notes.md
|
||||
fi
|
||||
|
||||
- name: Login to image registry
|
||||
run: |
|
||||
echo "${{ secrets.CMS_IMAGE_REGISTRY_PASSWORD }}" | docker login "${{ env.REGISTRY }}" -u "${{ secrets.CMS_IMAGE_REGISTRY_USER }}" --password-stdin
|
||||
@@ -65,18 +77,27 @@ jobs:
|
||||
docker build -f apps/admin/Dockerfile -t "$image" .
|
||||
docker push "$image"
|
||||
|
||||
- name: Release notes placeholder
|
||||
run: |
|
||||
echo "Release tag: ${{ steps.tag.outputs.value }}"
|
||||
echo "TODO: publish CHANGELOG.md content to release notes in Gitea."
|
||||
- name: Publish release notes to Gitea
|
||||
env:
|
||||
RELEASE_TAG: ${{ steps.tag.outputs.value }}
|
||||
RELEASE_NAME: ${{ steps.tag.outputs.value }}
|
||||
RELEASE_BODY_FILE: ".gitea-release-notes.md"
|
||||
GITEA_RELEASE_TOKEN: ${{ secrets.GITEA_RELEASE_TOKEN }}
|
||||
run: bun .gitea/scripts/publish-gitea-release.mjs
|
||||
|
||||
rollback:
|
||||
name: Rollback (Manual)
|
||||
name: Rollback Production (Manual)
|
||||
if: github.event_name == 'workflow_dispatch' && github.event.inputs.rollback_image_tag != ''
|
||||
runs-on: ubuntu-latest
|
||||
needs: release
|
||||
runs-on: node22-bun
|
||||
steps:
|
||||
- name: Rollback placeholder
|
||||
- name: Setup SSH
|
||||
run: |
|
||||
echo "Rollback to image tag: ${{ github.event.inputs.rollback_image_tag }}"
|
||||
echo "TODO: apply compose update with rollback image tags on production host."
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.CMS_DEPLOY_KEY }}" > ~/.ssh/id_rsa
|
||||
chmod 600 ~/.ssh/id_rsa
|
||||
ssh-keyscan -H "${{ secrets.CMS_PRODUCTION_HOST }}" >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Apply rollback image tag on production
|
||||
run: |
|
||||
ssh "${{ secrets.CMS_PRODUCTION_USER }}@${{ secrets.CMS_PRODUCTION_HOST }}" \
|
||||
"cd ${{ secrets.CMS_REMOTE_DEPLOY_PATH }} && CMS_IMAGE_TAG=${{ github.event.inputs.rollback_image_tag }} docker compose -f docker-compose.production.yml pull && CMS_IMAGE_TAG=${{ github.event.inputs.rollback_image_tag }} docker compose -f docker-compose.production.yml up -d"
|
||||
|
||||
Reference in New Issue
Block a user