summaryrefslogtreecommitdiffstats
path: root/ansible_collections/hetzner/hcloud/.github/workflows/release-please.yml
blob: a5b035c141d0ff0ca6e008643a240beb36019462 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Release-please

on:
  push:
    branches: [main]

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  release-please:
    # Do not run on forks.
    if: github.repository == 'ansible-collections/hetzner.hcloud'

    runs-on: ubuntu-latest
    steps:
      - id: release
        uses: google-github-actions/release-please-action@v4
        with:
          token: ${{ secrets.HCLOUD_BOT_TOKEN }}
          config-file: .github/release-please-config.json
          manifest-file: .github/release-please-manifest.json

      - name: Prepare outputs
        id: outputs
        if: steps.release.outputs.pr != ''
        run: |
          echo "pr-updated=true" >> "$GITHUB_OUTPUT"
          echo "branch=${{ fromJSON(steps.release.outputs.pr).headBranchName }}" >> "$GITHUB_OUTPUT"
          echo "version=$(echo "${{ fromJSON(steps.release.outputs.pr).title }}" | awk '{print $3}')" >> "$GITHUB_OUTPUT"

    outputs:
      pr-updated: ${{ steps.outputs.outputs.pr-updated }}
      branch: ${{ steps.outputs.outputs.branch }}
      version: ${{ steps.outputs.outputs.version }}

  antsibull-changelog:
    needs: [release-please]
    if: needs.release-please.outputs.pr-updated

    runs-on: ubuntu-latest
    steps:
      - name: Setup python
        uses: actions/setup-python@v5
        with:
          python-version: "3.11"
      - name: Install dependencies
        run: pip install antsibull-changelog

      - uses: actions/checkout@v4
        with:
          ref: ${{ needs.release-please.outputs.branch }}

      - name: antsibull-changelog
        run: antsibull-changelog release --version "${{ needs.release-please.outputs.version }}"

      - name: Check for diff
        id: antsibull-diff
        run: |
          if [[ $(git status --porcelain) ]]; then
            echo "changed=true" >> "$GITHUB_OUTPUT"
          fi

      - name: Commit & Push
        if: ${{ steps.antsibull-diff.outputs.changed }}
        run: |
          git config user.name "Hetzner Cloud Bot"
          git config user.email "45457231+hcloud-bot@users.noreply.github.com"

          git add changelogs/ CHANGELOG.rst
          git commit -m "chore(main): changelog for version ${{ needs.release-please.outputs.version }}"

          git push --force origin ${{ needs.release-please.outputs.branch }}