From 6db093103e2caa48652dd18b81b9ad5d89cdf323 Mon Sep 17 00:00:00 2001 From: alex289 Date: Wed, 6 Dec 2023 10:00:25 +0100 Subject: [PATCH] feat: Create GitHub releases automatically --- .github/workflows/dotnet.yml | 29 +++++++++++++++++++++++++++-- version.json | 3 +++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 version.json diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 6b0880e..1f1840a 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -19,35 +19,60 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Install .NET Core uses: actions/setup-dotnet@v3 with: dotnet-version: | 8.x.x + - name: Restore dependencies run: dotnet restore + - name: Build run: dotnet build --no-restore + - name: Test run: dotnet test --no-build --verbosity normal cd: runs-on: ubuntu-latest needs: ci - if: github.ref == 'refs/heads/main' + if: github.event_name == 'workflow_run' steps: - name: Set up QEMU uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Login to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Read Version + id: read_version + run: echo ::set-output name=VERSION::$(jq -r '.version' version.json) + - name: Build and push uses: docker/build-push-action@v5 with: # platforms: linux/amd64,linux/arm64 push: true - tags: ${{ env.DOCKER_IMAGE }}:latest \ No newline at end of file + tags: ${{ env.DOCKER_IMAGE }}:${{ steps.read_version.outputs.VERSION }}, ${{ env.DOCKER_IMAGE }}:latest + + - name: Create and Push Tag + run: | + git config user.name "GitHub Actions" + git config user.email "actions@github.com" + git tag -a v${{ steps.read_version.outputs.VERSION }} -m "Version ${{ steps.read_version.outputs.VERSION }}" + git push origin v${{ steps.read_version.outputs.VERSION }} + + - name: Create Release + uses: softprops/action-gh-release@v1 + with: + title: v${{ steps.read_version.outputs.VERSION }} + tag_name: v${{ steps.read_version.outputs.VERSION }} + generate_release_notes: true diff --git a/version.json b/version.json new file mode 100644 index 0000000..dfba51c --- /dev/null +++ b/version.json @@ -0,0 +1,3 @@ +{ + "version": "0.1.0" +} \ No newline at end of file