From d6bfae23fc70aedb715af74c4b9e04801d73b075 Mon Sep 17 00:00:00 2001 From: Emil Kais Date: Mon, 30 Dec 2024 13:31:18 -0300 Subject: [PATCH] Try basic release publish --- .github/workflows/release-publish.yml | 198 +++----------------------- 1 file changed, 20 insertions(+), 178 deletions(-) diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml index e4320ecf17d8a..fd6d87f7f9ca5 100644 --- a/.github/workflows/release-publish.yml +++ b/.github/workflows/release-publish.yml @@ -1,188 +1,30 @@ -name: 'Release: Publish' +name: 'Build and Publish Docker Image' on: push: branches: - 'feat/*' - pull_request: - branches: - - 'feat/*' jobs: - publish-to-npm: - name: Publish to NPM - runs-on: ubuntu-latest - if: github.event.pull_request.merged == true - timeout-minutes: 10 - permissions: - id-token: write - env: - NPM_CONFIG_PROVENANCE: true - outputs: - release: ${{ steps.set-release.outputs.release }} - steps: - - name: Checkout - uses: actions/checkout@v4.1.1 - with: - fetch-depth: 0 - - - run: corepack enable - - uses: actions/setup-node@v4.0.2 - with: - node-version: 20.x - cache: 'pnpm' - - run: pnpm install --frozen-lockfile - - - name: Set release version in env - run: echo "RELEASE=$(node -e 'console.log(require("./package.json").version)')" >> $GITHUB_ENV - - - name: Build - run: pnpm build - - - name: Cache build artifacts - uses: actions/cache/save@v4.0.0 - with: - path: ./packages/**/dist - key: ${{ github.sha }}-release:build - - - name: Dry-run publishing - run: pnpm publish -r --no-git-checks --dry-run - - - name: Publish to NPM (Custom) - run: | - echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc - node .github/scripts/trim-fe-packageJson.js - node .github/scripts/ensure-provenance-fields.mjs - sed -i "s/default: 'dev'/default: 'stable'/g" packages/cli/dist/config/schema.js - pnpm publish -r --publish-branch ${{github.event.pull_request.base.ref}} --access public --tag rc --no-git-checks - npm dist-tag rm n8n rc - - - id: set-release - run: echo "release=${{ env.RELEASE }}" >> $GITHUB_OUTPUT - - publish-to-docker-hub: - name: Publish to Docker Hub - needs: [publish-to-npm] - runs-on: ubuntu-latest - if: github.event.pull_request.merged == true - timeout-minutes: 10 - - steps: - - name: Checkout - uses: actions/checkout@v4.1.1 - with: - fetch-depth: 0 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3.0.0 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3.0.0 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3.0.0 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Login to Bitovi Docker Hub - uses: docker/login-action@v2 - if: github.event_name != 'pull_request' - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - - name: Build - uses: docker/build-push-action@v5.1.0 - with: - context: ./docker/images/n8n - build-args: | - N8N_VERSION=${{ needs.publish-to-npm.outputs.release }} - platforms: linux/amd64,linux/arm64 - provenance: false - push: true - tags: | - ${{ secrets.DOCKER_USERNAME }}/n8n:${{ needs.publish-to-npm.outputs.release }} - ghcr.io/${{ github.repository_owner }}/n8n:${{ needs.publish-to-npm.outputs.release }} - - create-github-release: - name: Create a GitHub Release - needs: [publish-to-npm, publish-to-docker-hub] - runs-on: ubuntu-latest - if: github.event.pull_request.merged == true - timeout-minutes: 5 - - permissions: - contents: write - id-token: write - - steps: - - name: Create a Release on GitHub - uses: ncipollo/release-action@v1 - with: - commit: ${{github.event.pull_request.base.ref}} - tag: 'n8n@${{ needs.publish-to-npm.outputs.release }}' - prerelease: true - makeLatest: false - body: ${{github.event.pull_request.body}} - - create-sentry-release: - name: Create a Sentry Release - needs: [publish-to-npm, publish-to-docker-hub] + build-and-push: runs-on: ubuntu-latest - if: github.event.pull_request.merged == true - timeout-minutes: 5 - env: - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - SENTRY_ORG: ${{ secrets.SENTRY_ORG }} - - steps: - - uses: actions/checkout@v4.1.1 - - name: Restore cached build artifacts - uses: actions/cache/restore@v4.0.0 - with: - path: ./packages/**/dist - key: ${{ github.sha }}-release:build - - name: Create a frontend release - uses: getsentry/action-release@v1.7.0 - continue-on-error: true - with: - projects: ${{ secrets.SENTRY_FRONTEND_PROJECT }} - version: ${{ needs.publish-to-npm.outputs.release }} - sourcemaps: packages/editor-ui/dist - - - name: Create a backend release - uses: getsentry/action-release@v1.7.0 - continue-on-error: true - with: - projects: ${{ secrets.SENTRY_BACKEND_PROJECT }} - version: ${{ needs.publish-to-npm.outputs.release }} - sourcemaps: packages/cli/dist packages/core/dist packages/nodes-base/dist packages/@n8n/n8n-nodes-langchain/dist - - trigger-release-note: - name: Trigger a release note - needs: [publish-to-npm, create-github-release] - if: github.event.pull_request.merged == true - runs-on: ubuntu-latest steps: - - name: Trigger a release note - run: curl -u docsWorkflows:${{ secrets.N8N_WEBHOOK_DOCS_PASSWORD }} --request GET 'https://internal.users.n8n.cloud/webhook/trigger-release-note' --header 'Content-Type:application/json' --data '{"version":"${{ needs.publish-to-npm.outputs.release }}"}' - - # merge-back-into-master: - # name: Merge back into master - # needs: [publish-to-npm, create-github-release] - # if: ${{ github.event.pull_request.merged == true && !contains(github.event.pull_request.labels.*.name, 'release:patch') }} - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4.1.1 - # with: - # fetch-depth: 0 - # - run: | - # git checkout --track origin/master - # git config user.name "github-actions[bot]" - # git config user.email 41898282+github-actions[bot]@users.noreply.github.com - # git merge --ff n8n@${{ needs.publish-to-npm.outputs.release }} - # git push origin master - # git push origin :${{github.event.pull_request.base.ref}} + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and Push Docker Image + uses: docker/build-push-action@v3 + with: + context: . + push: true + tags: ${{ secrets.DOCKER_USERNAME }}/your-image-name:latest