|
1 | | -name: release_pr |
2 | | - |
3 | | -on: |
4 | | - push: |
5 | | - branches: |
6 | | - - master |
7 | | - |
8 | | -jobs: |
9 | | - release-pr: |
10 | | - runs-on: ubuntu-latest |
11 | | - steps: |
12 | | - - name: Checkout |
13 | | - uses: actions/checkout@v4 |
14 | | - - name: Unshallow |
15 | | - run: git fetch --prune --unshallow |
16 | | - |
17 | | - # git-cliff generates CHANGELOG.md |
18 | | - - uses: actions/setup-python@v5 |
19 | | - with: |
20 | | - python-version: '3.10' |
21 | | - - run: pip install git-cliff==2.4.0 typos |
22 | | - - name: Check new changlog entry for version bump type |
23 | | - id: type |
24 | | - run: | |
25 | | - changelog=$(git cliff --unreleased) |
26 | | - case $changelog in |
27 | | - *"BREAKING CHANGES:"* ) |
28 | | - echo "MAJOR" |
29 | | - echo "bump="MAJOR: version change"" >> $GITHUB_OUTPUT |
30 | | - ;; |
31 | | - *"IMPROVEMENTS:"* ) |
32 | | - echo "MINOR" |
33 | | - echo "bump="MINOR: version change"" >> $GITHUB_OUTPUT |
34 | | - ;; |
35 | | - *"DEPRECATIONS:"* ) |
36 | | - echo "MINOR" |
37 | | - echo "bump="MINOR: version change"" >> $GITHUB_OUTPUT |
38 | | - ;; |
39 | | - * ) |
40 | | - echo "PATCH" |
41 | | - echo "bump="PATCH: version change"" >> $GITHUB_OUTPUT |
42 | | - ;; |
43 | | - esac |
44 | | - # The --with-commit inserts a commit message to git-cliff without it being in the history. |
45 | | - # It is used here to dynamically add version bump commands. |
46 | | - - name: Get next version |
47 | | - id: vars |
48 | | - run: echo "version=$(git cliff --bumped-version --with-commit "${{ steps.type.outputs.bump }}")" >> $GITHUB_OUTPUT |
49 | | - - name: Generate changelog output |
50 | | - run: git cliff --bump --unreleased --with-commit "${{ steps.type.outputs.bump }}" |
51 | | - - name: Prepend new changelog entry |
52 | | - run: git cliff --bump --unreleased -p CHANGELOG.md --with-commit "${{ steps.type.outputs.bump }}" |
53 | | - |
54 | | - # Commit changes to release_pr branch |
55 | | - - name: Set git config |
56 | | - run: git config user.email "[email protected]" && git config user.name "dcne-automation" |
57 | | - - name: Commit |
58 | | - run: git add -u && git status && git commit -m "[ignore] Update CHANGELOG.md for ${{ steps.vars.outputs.version }} release" |
59 | | - - name: Branch & Push |
60 | | - run: git checkout -b release_pr && git push --set-upstream origin release_pr --force && git clean -f -d |
61 | | - |
62 | | - # Create or update release PR |
63 | | - - run: gh pr create --base master --head release_pr --title "Pre-Release PR (${{ steps.vars.outputs.version }})" --body "" |
64 | | - id: pr |
65 | | - continue-on-error: true |
66 | | - env: |
67 | | - GH_TOKEN: ${{ secrets.DCNE_AUTO_TOKEN }} |
68 | | - - run: gh pr edit release_pr --title "Pre-Release PR (${{ steps.vars.outputs.version }})" |
69 | | - if: steps.pr.outcome == 'failure' |
70 | | - env: |
71 | | - GH_TOKEN: ${{ secrets.DCNE_AUTO_TOKEN }} |
| 1 | +name: release_pr |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + |
| 8 | +jobs: |
| 9 | + release-pr: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: Checkout |
| 13 | + uses: actions/checkout@v4 |
| 14 | + - name: Unshallow |
| 15 | + run: git fetch --prune --unshallow |
| 16 | + |
| 17 | + # git-cliff generates CHANGELOG.md |
| 18 | + - uses: actions/setup-python@v5 |
| 19 | + with: |
| 20 | + python-version: '3.10' |
| 21 | + - run: pip install git-cliff==2.4.0 typos |
| 22 | + - name: Check new changlog entry for version bump type |
| 23 | + id: type |
| 24 | + run: | |
| 25 | + changelog=$(git cliff --unreleased) |
| 26 | + case $changelog in |
| 27 | + *"BREAKING CHANGES:"* ) |
| 28 | + echo "MAJOR" |
| 29 | + echo "bump="MAJOR: version change"" >> $GITHUB_OUTPUT |
| 30 | + ;; |
| 31 | + *"IMPROVEMENTS:"* ) |
| 32 | + echo "MINOR" |
| 33 | + echo "bump="MINOR: version change"" >> $GITHUB_OUTPUT |
| 34 | + ;; |
| 35 | + *"DEPRECATIONS:"* ) |
| 36 | + echo "MINOR" |
| 37 | + echo "bump="MINOR: version change"" >> $GITHUB_OUTPUT |
| 38 | + ;; |
| 39 | + * ) |
| 40 | + echo "PATCH" |
| 41 | + echo "bump="PATCH: version change"" >> $GITHUB_OUTPUT |
| 42 | + ;; |
| 43 | + esac |
| 44 | + # The --with-commit inserts a commit message to git-cliff without it being in the history. |
| 45 | + # It is used here to dynamically add version bump commands. |
| 46 | + - name: Get next version |
| 47 | + id: vars |
| 48 | + run: echo "version=$(git cliff --bumped-version --with-commit "${{ steps.type.outputs.bump }}")" >> $GITHUB_OUTPUT |
| 49 | + - name: Generate changelog output |
| 50 | + run: git cliff --bump --unreleased --with-commit "${{ steps.type.outputs.bump }}" |
| 51 | + - name: Prepend new changelog entry |
| 52 | + run: git cliff --bump --unreleased -p CHANGELOG.md --with-commit "${{ steps.type.outputs.bump }}" |
| 53 | + |
| 54 | + # Generate SBOM |
| 55 | + - name: Generate SBOM SPDX JSON file |
| 56 | + uses: anchore/sbom-action@v0 |
| 57 | + with: |
| 58 | + path: ./ |
| 59 | + artifact-name: sbom.spdx.json |
| 60 | + output-file: ./sbom.spdx.json |
| 61 | + env: |
| 62 | + SYFT_EXCLUDE: ./.github |
| 63 | + - name: Beautify SBOM JSON file |
| 64 | + run: python -m json.tool sbom.spdx.json sbom.spdx.json |
| 65 | + |
| 66 | + # Commit changes to release_pr branch |
| 67 | + - name: Set git config |
| 68 | + run: git config user.email "[email protected]" && git config user.name "dcne-automation" |
| 69 | + - name: Commit |
| 70 | + run: git add -u && git status && git commit -m "[ignore] Update CHANGELOG.md and sbom.spdx.json for ${{ steps.vars.outputs.version }} release" |
| 71 | + - name: Branch & Push |
| 72 | + run: git checkout -b release_pr && git push --set-upstream origin release_pr --force && git clean -f -d |
| 73 | + |
| 74 | + # Create or update release PR |
| 75 | + - run: gh pr create --base master --head release_pr --title "Pre-Release PR (${{ steps.vars.outputs.version }})" --body "" |
| 76 | + id: pr |
| 77 | + continue-on-error: true |
| 78 | + env: |
| 79 | + GH_TOKEN: ${{ secrets.DCNE_AUTO_TOKEN }} |
| 80 | + - run: gh pr edit release_pr --title "Pre-Release PR (${{ steps.vars.outputs.version }})" |
| 81 | + if: steps.pr.outcome == 'failure' |
| 82 | + env: |
| 83 | + GH_TOKEN: ${{ secrets.DCNE_AUTO_TOKEN }} |
0 commit comments