From 0b06b60de551b125c9c45753bed5b468cef20614 Mon Sep 17 00:00:00 2001 From: Alexey Kotlyarov Date: Fri, 15 Mar 2024 21:42:33 +1100 Subject: [PATCH] feat: Semantic release --- .github/workflows/main.yaml | 68 +++++++++++++------------------------ .releaserc.json | 17 ++++++++++ 2 files changed, 40 insertions(+), 45 deletions(-) create mode 100644 .releaserc.json diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 0197910..c1c6007 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -1,29 +1,22 @@ -name: Build - +name: CI on: push: branches: - - main - tags: - - v[0-9]+.[0-9]+.[0-9]+ + - 'main' pull_request: - branches: - - main - schedule: - - cron: "0 0 * * 5" jobs: build: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install system dependencies run: sudo ./install-deps - name: Set up Stack - run: stack upgrade || curl -sSL https://get.haskellstack.org/ | sh -s - -f + uses: freckle/stack-action@v5 - name: Set up cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: key: stack path: ~/.stack @@ -34,41 +27,26 @@ jobs: run: | stack --no-terminal test - release: - if: startsWith(github.ref, 'refs/tags/v') - needs: build + publish: + needs: + - build runs-on: ubuntu-latest + permissions: + contents: write steps: - name: Checkout - uses: actions/checkout@v3 - - name: Set up Stack - run: stack upgrade || curl -sSL https://get.haskellstack.org/ | sh -s - -f - - name: Set up cache - uses: actions/cache@v3 - with: - key: stack - path: ~/.stack - - name: Build - run: | - stack --no-terminal build --copy-bins --local-bin-path . - - name: Log in to the Container registry - uses: docker/login-action@v2 + uses: actions/checkout@v4 with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Calculate Docker tag - id: tag - uses: frabert/replace-string-action@v2.0 + fetch-depth: 0 + - name: Setup Node.js + uses: actions/setup-node@v4 with: - pattern: '^refs/tags/' - string: ${{ github.ref }} - replace-with: '' - - name: Build and push Docker image - uses: docker/build-push-action@v4 - with: - context: . - push: true - tags: | - ghcr.io/koterpillar/multiblog:${{ steps.tag.outputs.replaced }}, - ghcr.io/koterpillar/multiblog:latest + node-version: 20 + - name: Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + npx \ + --package @codedependant/semantic-release-docker@4 \ + --package semantic-release@18 \ + semantic-release diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 0000000..dbe22c5 --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,17 @@ +{ + "branches": ["main"], + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + [ + "@codedependant/semantic-release-docker", + { + "dockerRegistry": "ghcr.io", + "dockerProject": "koterpillar", + "dockerImage": "multiblog", + "dockerTags": ["latest", "{{version}}"] + } + ], + "@semantic-release/github" + ] +}