From 219fbbe4b3b005f23ee07ac87784a52ad555e471 Mon Sep 17 00:00:00 2001 From: Oscar Mulder Date: Thu, 14 Jul 2022 13:19:33 +0200 Subject: [PATCH] use semantic release for automated release --- .github/workflows/deploy-image.yml | 38 ++++++++++-------------------- package.json | 10 ++++---- release.config.js | 12 ++++++++++ 3 files changed, 28 insertions(+), 32 deletions(-) create mode 100644 release.config.js diff --git a/.github/workflows/deploy-image.yml b/.github/workflows/deploy-image.yml index d82ebde..45a230f 100644 --- a/.github/workflows/deploy-image.yml +++ b/.github/workflows/deploy-image.yml @@ -4,8 +4,6 @@ on: push: branches: - main - tags: - - '*' env: REGISTRY: ghcr.io @@ -22,6 +20,14 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: 'lts/*' + + - name: Install dependencies + run: npm ci + - name: Log in to the Container registry uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b # v2.0.0 with: @@ -29,27 +35,7 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@69f6fc9d46f2f8bf0d5491e4aabe0bb8c6a4678a # v4.0.1 - with: - images: | - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - - - name: Build and push Docker image - uses: docker/build-push-action@e551b19e49efd4e98792db7592c17c09b89db8d8 # v3.0.0 - with: - context: . - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - # - uses: google-github-actions/release-please-action@v3 - # with: - # release-type: node - # package-name: ${{ env.IMAGE_NAME }} + - name: Build & Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: npx semantic-release diff --git a/package.json b/package.json index b9993bd..d42bb45 100644 --- a/package.json +++ b/package.json @@ -36,10 +36,8 @@ "release": { "branches": ["main"] }, - "publish": [ - { - "path": "semantic-release-docker", - "name": "ghcr.io/codam-coding-college/internal-clustermap" - } - ] + "repository": { + "type": "git", + "url": "https://github.com/codam-coding-college/internal-clustermap.git" + } } diff --git a/release.config.js b/release.config.js new file mode 100644 index 0000000..b6c12b6 --- /dev/null +++ b/release.config.js @@ -0,0 +1,12 @@ +module.exports = { + branches: ['main'], + plugins: [ + ['@codedependant/semantic-release-docker', { + dockerTags: ['latest', '{{version}}', '{{major}}-latest', '{{major}}.{{minor}}'], + dockerImage: 'internal-clustermap', + dockerFile: 'Dockerfile', + dockerRegistry: 'ghcr.io', + dockerProject: 'codam-coding-college', + }] + ] + }