From 88ecb65dca49040295fb3bca06d0f7d3e32e727f Mon Sep 17 00:00:00 2001 From: Rafael Augusto de Oliveira Date: Sun, 24 Mar 2024 18:54:30 +0000 Subject: [PATCH] ci(github-actions): add semantic release --- .github/workflows/continuous_delivery.yml | 44 ++++++++++++++++++----- .releaserc.json | 26 ++++++++++++++ 2 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 .releaserc.json diff --git a/.github/workflows/continuous_delivery.yml b/.github/workflows/continuous_delivery.yml index af7f74f..30b9fdb 100644 --- a/.github/workflows/continuous_delivery.yml +++ b/.github/workflows/continuous_delivery.yml @@ -2,8 +2,14 @@ name: Continuous Delivery on: push: - tags: - - "*.*.*" + branches: + - main + + pull_request: + branches: + - main + + workflow_dispatch: jobs: build: @@ -12,27 +18,49 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: "14" + + - name: Release to GitHub + id: semantic-releases + uses: cycjimmy/semantic-release-action@v2.5.4 + with: + semantic_version: 18.0.0 + extra_plugins: | + @semantic-release/changelog@5.0.1 + @semantic-release/git + branches: | + ['main'] + env: + GITHUB_TOKEN: ${{ secrets._GITHUB_TOKEN }} + - name: Docker metadata id: meta uses: docker/metadata-action@v4 + if: steps.semantic-releases.outputs.new_release_published == 'true' with: images: ${{ secrets.DOCKERHUB_USERNAME }}/tastytrade-ghostfolio tags: | - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - + type=semver,pattern={{version}},value=${{ steps.semantic-releases.outputs.new_release_version }} + type=semver,pattern={{major}}.{{minor}},value=${{ steps.semantic-releases.outputs.new_release_version }} + type=semver,pattern={{major}},value=${{ steps.semantic-releases.outputs.new_release_version }} + - name: Login to Docker Hub uses: docker/login-action@v3 + if: steps.semantic-releases.outputs.new_release_published == 'true' with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - + if: steps.semantic-releases.outputs.new_release_published == 'true' + - name: Build and Publish to Docker Hub uses: docker/build-push-action@v5 + if: steps.semantic-releases.outputs.new_release_published == 'true' with: context: . platforms: linux/amd64 diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 0000000..297efdf --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,26 @@ +{ + "branches": [ + "main" + ], + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + [ + "@semantic-release/changelog", + { + "changelogFile": "CHANGELOG.md", + "changelogTitle": "# Changelog\n\nAll notable changes to this project will be documented in this file." + } + ], + "@semantic-release/github", + [ + "@semantic-release/git", + { + "assets": [ + "CHANGELOG.md" + ], + "message": "chore(release): version ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" + } + ] + ] +} \ No newline at end of file