From ff00f0ad193478186af4d1a1037b64ba9b1ceb35 Mon Sep 17 00:00:00 2001 From: Luke Tainton Date: Tue, 18 Feb 2025 23:00:55 +0100 Subject: [PATCH] Update .gitea/workflows/release.yml --- .gitea/workflows/release.yml | 72 ++++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 6556986..bdc6c42 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -15,12 +15,76 @@ jobs: SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }} SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} + # create_release: + # name: Create Release + # needs: test + # uses: https://git.tainton.uk/actions/gha-workflows/.gitea/workflows/create-release.yml@main + # secrets: + # ACTIONS_TOKEN: ${{ secrets.ACTIONS_TOKEN }} + create_release: name: Create Release - needs: test - uses: https://git.tainton.uk/actions/gha-workflows/.gitea/workflows/create-release.yml@main - secrets: - ACTIONS_TOKEN: ${{ secrets.ACTIONS_TOKEN }} + runs-on: ubuntu-latest + # needs: test + outputs: + release_name: ${{ steps.get_next_version.outputs.tag }} + steps: + - name: Check out repository + uses: actions/checkout@v4.2.2 + with: + fetch-depth: 0 + + - name: Changes since last tag + id: changes + run: | + rm -f .changes + git log $(git describe --tags --abbrev=0)..HEAD --no-merges --oneline >> .changes + cat .changes + + - name: Check for changes + run: | + if [[ -z $(grep '[^[:space:]]' .changes) ]] ; then + echo "changes=false" + echo "changes=false" >> "$GITEA_OUTPUT" + else + echo "changes=true" + echo "changes=true" >> "$GITEA_OUTPUT" + fi + + - name: Cancel if no changes + if: steps.changes.outputs.changes == 'false' + run: exit 1 + + - name: Set server URL + id: set_srvurl + run: | + SRVURL=$(echo "${{ gitea.server_url }}" | sed 's/https:\/\/\(.*\)/\1/') + echo "srvurl=$SRVURL" >> "$GITEA_OUTPUT" + + - name: Get next version + uses: TriPSs/conventional-changelog-action@v6 + id: get_next_version + with: + git-url: ${{ steps.set_srvurl.outputs.srvurl }} + github-token: ${{ gitea.token }} + preset: "conventionalcommits" + # preset: "angular" # This is the default + skip-commit: true + release-count: 1 + output-file: false + create-summary: true + skip-on-empty: true + skip-version-file: true + skip-tag: true + + - name: Create release + run: | + curl -s -X POST \ + -H "Authorization: token ${{ secrets.ACTIONS_TOKEN }}" \ + -H "accept: application/json" \ + -H "Content-Type: application/json" \ + -d "{\"tag_name\": \"${{ steps.get_next_version.outputs.tag }}\", \"name\": \"${{ steps.get_next_version.outputs.tag }}\", \"body\": \"${{ steps.get_next_version.outputs.changelog }}\"}" \ + "${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases" print_release: name: Print Release