diff --git a/.github/workflows/reusable-changelog.yml b/.github/workflows/reusable-changelog.yml index 72b4fc1..802c8db 100644 --- a/.github/workflows/reusable-changelog.yml +++ b/.github/workflows/reusable-changelog.yml @@ -36,6 +36,12 @@ jobs: - run: npm ci working-directory: site + - name: List the tags before + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} + REPOSITORY: ${{ github.repository }} + run: gh api "repos/${REPOSITORY}/tags" --paginate --jq '.[].name' | sort > "${RUNNER_TEMP}/tags-before" + - name: Tag a new version and draft its entries working-directory: site env: @@ -43,6 +49,18 @@ jobs: REPOSITORY: ${{ github.repository }} run: npm run sync:releases -- --cut "--repo=${REPOSITORY}" + - name: Publish a GitHub release for each new tag + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} + REPOSITORY: ${{ github.repository }} + run: | + set -euo pipefail + gh api "repos/${REPOSITORY}/tags" --paginate --jq '.[].name' | sort > "${RUNNER_TEMP}/tags-after" + comm -13 "${RUNNER_TEMP}/tags-before" "${RUNNER_TEMP}/tags-after" | while read -r tag; do + gh release create "$tag" --repo "$REPOSITORY" --verify-tag --generate-notes --title "$tag" + echo "Published the ${tag} release." + done + - run: node scripts/compile.mjs working-directory: site diff --git a/.github/workflows/reusable-deploy.yml b/.github/workflows/reusable-deploy.yml index c47ece7..1c7285b 100644 --- a/.github/workflows/reusable-deploy.yml +++ b/.github/workflows/reusable-deploy.yml @@ -59,32 +59,34 @@ jobs: echo "slug=${SLUG}" >> "$GITHUB_OUTPUT" echo "kind=${kind}" >> "$GITHUB_OUTPUT" - - name: Record tags + - name: Record the image tag if: ${{ steps.entry.outputs.kind == 'compose' || steps.entry.outputs.kind == 'pages' }} env: - SERVICES: ${{ inputs.services }} TAG: ${{ inputs.tag }} SLUG: ${{ steps.entry.outputs.slug }} run: | set -euo pipefail export TAG="${TAG:-sha-${GITHUB_SHA::7}}" + if [ ! -d "deploy/${SLUG}" ]; then + echo "No deploy/${SLUG}/ in the platform repository, so ${SLUG} is not deployed; nothing to record." + exit 0 + fi + python3 - <<'PY' - import json, os, pathlib + import os, pathlib - path = pathlib.Path("tags") / f"{os.environ['SLUG']}.json" - path.parent.mkdir(exist_ok=True) - tags = json.loads(path.read_text()) if path.exists() else {} - tags.update(dict.fromkeys(json.loads(os.environ["SERVICES"]), os.environ["TAG"])) - path.write_text(json.dumps(tags, indent=2, sort_keys=True) + "\n") + path = pathlib.Path("deploy") / os.environ["SLUG"] / "values" + lines = [line for line in (path.read_text().splitlines() if path.exists() else []) if not line.startswith("IMAGE_TAG=")] + path.write_text("\n".join([f"IMAGE_TAG={os.environ['TAG']}", *lines]) + "\n") PY git config user.name "graphite-deploy" git config user.email "deploy@project-graphite.com" - git add "tags/${SLUG}.json" + git add "deploy/${SLUG}/values" if git diff --cached --quiet; then - echo "Tags already at ${TAG}; nothing to record." + echo "IMAGE_TAG is already ${TAG}; nothing to record." exit 0 fi diff --git a/.github/workflows/reusable-sync-registry.yml b/.github/workflows/reusable-sync-registry.yml deleted file mode 100644 index def79ba..0000000 --- a/.github/workflows/reusable-sync-registry.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: Sync registry - -on: - workflow_call: - -jobs: - dispatch: - name: Request registry sync - runs-on: ubuntu-latest - permissions: - contents: read - steps: - - uses: actions/checkout@v7 - with: - persist-credentials: false - - - uses: actions/create-github-app-token@v3 - id: read-token - with: - client-id: ${{ secrets.PLATFORM_APP_CLIENT_ID }} - private-key: ${{ secrets.PLATFORM_APP_PRIVATE_KEY }} - owner: ${{ github.repository_owner }} - permission-contents: read - - - uses: actions/checkout@v7 - with: - repository: ${{ github.repository_owner }}/platform - token: ${{ steps.read-token.outputs.token }} - path: .platform - persist-credentials: false - - - uses: actions/setup-python@v7 - with: - python-version: "3.14" - - - run: pip install pyyaml jsonschema - - - name: Validate .graphite.yml - env: - GH_TOKEN: ${{ steps.read-token.outputs.token }} - run: python .platform/scripts/sync.py "${{ github.event.repository.name }}" .graphite.yml - - - uses: actions/create-github-app-token@v3 - id: app-token - with: - client-id: ${{ secrets.PLATFORM_APP_CLIENT_ID }} - private-key: ${{ secrets.PLATFORM_APP_PRIVATE_KEY }} - owner: ${{ github.repository_owner }} - repositories: platform - permission-contents: write - - - name: Dispatch to the registry - env: - GH_TOKEN: ${{ steps.app-token.outputs.token }} - run: | - gh api "repos/${{ github.repository_owner }}/platform/dispatches" \ - --field event_type=sync-registry