diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2276e50d..0669ec66 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -92,7 +92,7 @@ jobs: cache-to: type=gha, scope=${{ github.workflow }} - name: Version tag - if: github.event_name != 'pull_request' + if: github.event_name == 'disabled_now' uses: arabcoders/action-python-autotagger@master with: token: ${{ secrets.GITHUB_TOKEN }} @@ -102,7 +102,7 @@ jobs: dockerhub-sync-readme: needs: push-build - if: github.event_name != 'pull_request' + if: github.event_name == 'push' runs-on: ubuntu-latest steps: - name: Sync README @@ -116,3 +116,72 @@ jobs: with: entrypoint: node args: /opt/docker-readme-sync/sync + + create_release: + needs: push-build + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/master' && github.event_name == 'push' && success() + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 # so we can git log the full history + + - name: Get commits between old and new + id: commits + run: | + PREVIOUS_SHA="${{ github.event.before }}" + CURRENT_SHA="${{ github.event.after }}" + + echo "Previous SHA: $PREVIOUS_SHA" + echo "Current SHA: $CURRENT_SHA" + + # If "before" is empty or all zeros, log all commits + if [ -z "$PREVIOUS_SHA" ] || [ "$PREVIOUS_SHA" = "0000000000000000000000000000000000000000" ]; then + LOG=$(git log --pretty=format:"- %h %s by %an") + else + LOG=$(git log "$PREVIOUS_SHA".."$CURRENT_SHA" --pretty=format:"- %h %s by %an") + fi + + echo "LOG<> "$GITHUB_ENV" + echo "$LOG" >> "$GITHUB_ENV" + echo "EOF" >> "$GITHUB_ENV" + + - name: Create local tag matching Docker's raw pattern + id: createtag + run: | + # We'll replicate raw format: branch + base_ref + date + short sha + # If base_ref is empty (normal push to master, no PR?), it won't appear. + BRANCH_NAME="${{ github.ref_name }}" + BASE_REF="${{ github.base_ref }}" + CURRENT_SHA="${{ github.event.after }}" + DATE=$(date +%Y%m%d) + SHORT_SHA=$(echo "$CURRENT_SHA" | cut -c1-7) + + TAG="${BRANCH_NAME}${BASE_REF}-${DATE}-${SHORT_SHA}" + + echo "Using tag: $TAG" + + git config user.name "github-actions" + git config user.email "github-actions@github.com" + + # Create a lightweight local tag + git tag "$TAG" "$CURRENT_SHA" + + # Push the tag back to GitHub + git push origin "$TAG" + + # Expose as an output + echo "TAG=$TAG" >> "$GITHUB_OUTPUT" + - name: Create GitHub Release + uses: softprops/action-gh-release@master + with: + tag_name: ${{ steps.createtag.outputs.TAG }} + name: "${{ steps.createtag.outputs.TAG }}" + body: ${{ env.LOG }} + draft: false + prerelease: false + generate_release_notes: true + append_body: true + make_latest: true + token: ${{ secrets.GITHUB_TOKEN }}