From 5f637af3cf1a8f65e9082f7c95f363ec31e286be Mon Sep 17 00:00:00 2001 From: Fabien O'Carroll Date: Thu, 26 Sep 2024 15:29:12 +0700 Subject: [PATCH] Added workflow for deploying @tryghost/admin-x-activitypub ref https://linear.app/tryghost/issue/AP-438 This will build and release the Admin X activitypub app when we bumb the package.json version and push to `main` --- .github/workflows/ci.yml | 60 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3e542caa57..29a1490947 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -999,3 +999,63 @@ jobs: inputs: '{"version":"canary","environment":"staging","version_extra":"${{ env.branch_name }}"}' wait-for-completion-timeout: 25m wait-for-completion-interval: 30s + + publish_admin_x_activitypub: + needs: [ + job_setup, + job_lint, + job_unit-tests + ] + name: Publish @tryghost/admin-x-activitypub + runs-on: ubuntu-latest + if: always() && needs.job_setup.result == 'success' && needs.job_lint.result == 'success' && needs.job_unit-tests.result == 'success' && needs.job_setup.outputs.is_main == 'true' + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '18.12.1' + + - name: Restore caches + uses: ./.github/actions/restore-cache + env: + DEPENDENCY_CACHE_KEY: ${{ needs.job_setup.outputs.dependency_cache_key }} + + - name: Build the package + run: yarn run nx build @tryghost/admin-x-activitypub + + - name: Check if version changed + id: version_check + working-directory: apps/admin-x-activitypub + run: | + CURRENT_VERSION=$(cat package.json | jq -r .version) + PUBLISHED_VERSION=$(npm show @tryghost/admin-x-activitypub version || echo "0.0.0") + echo "Current version: $CURRENT_VERSION" + echo "Published version: $PUBLISHED_VERSION" + if [ "$CURRENT_VERSION" = "$PUBLISHED_VERSION" ]; then + echo "Version is unchanged." + echo "version_changed=false" >> $GITHUB_ENV + else + echo "Version has changed." + echo "version_changed=true" >> $GITHUB_ENV + fi + + - name: Configure .npmrc + run: | + echo "@tryghost:registry=https://registry.npmjs.org/" >> ~/.npmrc + echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc + + - name: Publish to npm + if: env.version_changed == 'true' + working-directory: apps/admin-x-activitypub + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npm publish --access public + + - name: Purge jsdelivr cache + uses: gacts/purge-jsdelivr-cache@v1 + with: + url: | + https://cdn.jsdelivr.net/npm/@tryghost/admin-x-activitypub@0/dist/admin-x-activitypub.js