From 38aa831ba6543c7287438a833115a0ba2308b54f Mon Sep 17 00:00:00 2001 From: akumar Date: Wed, 17 Apr 2024 09:51:43 +0200 Subject: [PATCH] fix: Automate release --- .github/workflows/approve-merge.yaml | 5 +- .github/workflows/build.yaml | 22 -------- .github/workflows/release.yaml | 76 ++++++++++------------------ 3 files changed, 28 insertions(+), 75 deletions(-) diff --git a/.github/workflows/approve-merge.yaml b/.github/workflows/approve-merge.yaml index ddc0bab..afee9fe 100644 --- a/.github/workflows/approve-merge.yaml +++ b/.github/workflows/approve-merge.yaml @@ -19,7 +19,6 @@ jobs: git checkout master git merge --ff origin/next git push -u origin master - - uses: benc-uk/workflow-dispatch@v1 + - uses: peter-evans/repository-dispatch@v3 with: - workflow: release.yaml - ref: master \ No newline at end of file + event-type: release_master \ No newline at end of file diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index baf55d0..4a53bdd 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -39,25 +39,3 @@ jobs: - uses: coverallsapp/github-action@master with: github-token: ${{ secrets.GITHUB_TOKEN }} - - image: - runs-on: ubuntu-22.04 - needs: build - steps: - - uses: actions/checkout@v4 - - - uses: docker/setup-buildx-action@v3 - - - name: Set variables - id: vars - run: | - echo ::set-output name=version_tag::$(echo ${GITHUB_REF#refs/*/}) - echo ::set-output name=repo_name::$(echo ${GITHUB_REPOSITORY#*/*}) - - - uses: docker/build-push-action@v5 - with: - platforms: linux/amd64 - build-args: | - APP_HOME=/home/node/${{ steps.vars.outputs.repo_name }} - cache-from: | - ${{ github.repository }}:latest diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0ac0cde..acfb031 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -5,69 +5,45 @@ on: branches: - master workflow_dispatch: - -permissions: - contents: read + types: [release_master] jobs: release: - permissions: - contents: write - issues: write - pull-requests: write runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v4 with: + fetch-depth: 0 ref: master - - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.CR_PAT }} - - - uses: docker/setup-buildx-action@v3 - with: - install: true - - - name: Set variables - id: vars - run: | - echo ::set-output name=repo_name::$(echo ${GITHUB_REPOSITORY#*/*}) - - - uses: docker/metadata-action@v5 - id: docker_meta - with: - images: ${{ github.repository }} - - - uses: docker/build-push-action@v5 - with: - load: true - build-args: | - APP_HOME=/home/node/${{ steps.vars.outputs.repo_name }} - tags: ${{ github.repository }} - labels: ${{ steps.docker_meta.outputs.labels }} - - - uses: actions/setup-node@v4 + - name: Setup NodeJS + uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' - name: Install Dependencies run: npm clean-install - - run: npx semantic-release@22.0.12 + - name: Git Config + run: | + git config --global user.email "bot@restorecommerce.io" + git config --global user.name "Restorecommerce Bot" + + - name: Build + run: npm run build -- --verbose + + - name: NPM Token env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: | + echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" > .npmrc - - uses: benc-uk/workflow-dispatch@v1 - with: - workflow: upgrade-services.yaml - ref: master - repo: restorecommerce/charts - token: "${{ secrets.CHARTS_WORKFLOW_TOKEN }}" + - name: Release + run: npx lerna publish --no-verify-access --no-private --conventional-commits --yes --loglevel debug + + - name: Sync next branch + run: | + git checkout next + git merge master + git push -u origin next