diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index a73da96..3f10bac 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -4,6 +4,8 @@ on: workflow_dispatch: push: branches: [ main ] + tags: + - 'v*' pull_request: branches: [ main ] @@ -38,7 +40,7 @@ jobs: cd: runs-on: ubuntu-latest needs: ci - if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') steps: - uses: actions/checkout@v4 @@ -67,9 +69,7 @@ jobs: platforms: linux/amd64,linux/arm64 push: true labels: ${{ steps.meta.outputs.labels }} - tags: | - ${{ env.DOCKER_IMAGE }}:latest - ${{ env.DOCKER_IMAGE }}:${{ github.sha }} + tags: ${{ steps.meta.outputs.tags }} - name: Docker Hub Description uses: peter-evans/dockerhub-description@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1dcadf9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,56 @@ +name: Release + +on: + workflow_dispatch: + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: calculate version + id: calculate-version + uses: bitshifted/git-auto-semver@v1 + + - name: Get previous tag + id: previousTag + run: | + name=$(git --no-pager tag --sort=creatordate | tail -2 | head -1) + echo "previousTag: $name" + echo "previousTag=$name" >> $GITHUB_ENV + + - name: Create new tag + run: | + git tag -a ${{ steps.calculate-version.outputs.version-string }} -m "Release ${{ steps.calculate-version.outputs.version-string }}" + git push origin ${{ steps.calculate-version.outputs.version-string }} + git checkout main + + - name: Update CHANGELOG + id: changelog + uses: requarks/changelog-action@v1 + with: + token: ${{ github.token }} + fromTag: ${{ github.calculate-version.outputs.version-string }} + toTag: ${{ env.previousTag }} + + - name: Create Release + uses: ncipollo/release-action@v1.14.0 + with: + allowUpdates: true + draft: false + makeLatest: true + name: ${{ github.calculate-version.outputs.version-string }} + body: ${{ steps.changelog.outputs.changes }} + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Commit CHANGELOG.md + uses: stefanzweifel/git-auto-commit-action@v5 + with: + branch: main + commit_message: 'docs: update CHANGELOG.md for ${{ github.calculate-version.outputs.version-string }} [skip ci]' + file_pattern: CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..6d35385 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [v1.0.0] - 2024-03-23 +_This is the initial release._ + +[v1.0.0]: https://github.com/alex289/CleanArchitecture/commits/v1.0.0