diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 463f6c9..599fa2e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,8 +1,5 @@ name: Release Workflow -on: - push: - tags: - - '[0-9]+.[0-9]+.[0-9]+' +on: [push] jobs: release: @@ -10,13 +7,33 @@ jobs: steps: - uses: actions/checkout@v3 - + with: + fetch-depth: 0 + - name: Install zip run: sudo apt-get install zip - name: Run deploy script run: bash deploy.sh + - name: Determine Tag + id: determine_tag + run: | + # Check if the last commit has a tag + TAG=$(git describe --tags --exact-match 2>/dev/null || echo "") + if [ -z "$TAG" ]; then + # Get the latest tag + LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) + # Increment the minor version + IFS='.' read -r -a VERSION_PARTS <<< "$LATEST_TAG" + VERSION_PARTS[2]=$((VERSION_PARTS[2]+1)) + TAG="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}" + # Create a new tag + git tag $TAG + git push origin $TAG + fi + echo "::set-output name=tag::$TAG" + - name: Create Release id: create_release run: | @@ -25,8 +42,8 @@ jobs: -H "Accept: application/json" \ -H "Content-Type: application/json" \ -d '{ - "tag_name": "${{ github.ref_name }}", - "name": "${{ github.ref_name }}", + "tag_name": "${{ steps.determine_tag.outputs.tag }}", + "name": "${{ steps.determine_tag.outputs.tag }}", "draft": false, "prerelease": false }' \ @@ -36,8 +53,7 @@ jobs: run: | RELEASE_ID=$(curl -s \ -H "Authorization: token ${{ secrets.JEBENI_TOKEN }}" \ - http://srv-captain--git:3000/api/v1/repos/dave/wow-Heimdall/releases/tags/${{ github.ref_name }} | jq -r '.id') - + http://srv-captain--git:3000/api/v1/repos/dave/wow-Heimdall/releases/tags/${{ steps.determine_tag.outputs.tag }} | jq -r '.id') curl -X POST \ -H "Authorization: token ${{ secrets.JEBENI_TOKEN }}" \ -H "Content-Type: application/zip" \