|
| 1 | +--- |
| 2 | +name: New release |
| 3 | + |
| 4 | +on: # yamllint disable-line rule:truthy |
| 5 | + workflow_dispatch: |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + |
| 10 | +jobs: |
| 11 | + generate_changelog: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + name: create release draft |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v2.3.4 |
| 16 | + with: |
| 17 | + fetch-depth: 0 |
| 18 | + |
| 19 | + - name: 'Get Previous tag' |
| 20 | + id: previoustag |
| 21 | + uses: "WyriHaximus/github-action-get-previous-tag@master" |
| 22 | + env: |
| 23 | + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
| 24 | + |
| 25 | + - name: calculate next version |
| 26 | + id: version |
| 27 | + uses: patrickjahns/version-drafter-action@v1 |
| 28 | + env: |
| 29 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 30 | + |
| 31 | + - name: Generate changelog |
| 32 | + uses: charmixer/auto-changelog-action@v1 |
| 33 | + with: |
| 34 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 35 | + future_release: ${{ steps.version.outputs.next-version }} |
| 36 | + |
| 37 | + - name: Generate readme |
| 38 | + uses: terraform-docs/gh-actions@main |
| 39 | + with: |
| 40 | + working-dir: . |
| 41 | + output-file: README.md |
| 42 | + output-method: inject |
| 43 | + |
| 44 | + - name: push changelog and readme |
| 45 | + uses: github-actions-x/commit@v2.6 |
| 46 | + with: |
| 47 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 48 | + push-branch: 'main' |
| 49 | + commit-message: 'update changelog' |
| 50 | + force-add: 'true' |
| 51 | + files: CHANGELOG.md README.md |
| 52 | + name: T-Systems MMS |
| 53 | + email: frage@t-systems-mms.com |
| 54 | + |
| 55 | + # do a second checkout to prevent race situation |
| 56 | + # changelog gets updated but action works on old commit id |
| 57 | + - uses: actions/checkout@v2.3.4 |
| 58 | + with: |
| 59 | + ref: main |
| 60 | + |
| 61 | + - name: Generate changelog for the release |
| 62 | + run: | |
| 63 | + sed '/## \[${{ steps.previoustag.outputs.tag }}\]/Q' CHANGELOG.md > CHANGELOGRELEASE.md |
| 64 | + - name: Read CHANGELOG.md |
| 65 | + id: package |
| 66 | + uses: juliangruber/read-file-action@v1 |
| 67 | + with: |
| 68 | + path: ./CHANGELOGRELEASE.md |
| 69 | + |
| 70 | + - name: Create Release draft |
| 71 | + id: create_release |
| 72 | + uses: actions/create-release@v1 |
| 73 | + env: |
| 74 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token |
| 75 | + with: |
| 76 | + release_name: ${{ steps.version.outputs.next-version }} |
| 77 | + tag_name: ${{ steps.version.outputs.next-version }} |
| 78 | + body: | |
| 79 | + ${{ steps.package.outputs.content }} |
| 80 | + draft: true |
0 commit comments