|
| 1 | +name: Release - create draft release |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + tag-name: |
| 6 | + description: 'Name of git tag to be created, and then draft release created. Syntax: "v[0-9]+.[0-9]+.[0-9]+".' |
| 7 | + required: true |
| 8 | + from-tag-name: |
| 9 | + description: 'Name of the git tag from which to detect changes from. Default value: latest tag. Syntax: "v[0-9]+.[0-9]+.[0-9]+".' |
| 10 | + required: false |
| 11 | + |
| 12 | +jobs: |
| 13 | + release-draft: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + fetch-depth: 0 |
| 19 | + persist-credentials: false |
| 20 | + |
| 21 | + |
| 22 | + with: |
| 23 | + python-version: '3.11' |
| 24 | + |
| 25 | + - name: Check format of received tag |
| 26 | + id: check-version-tag |
| 27 | + |
| 28 | + env: |
| 29 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 30 | + with: |
| 31 | + github-repository: ${{ github.repository }} |
| 32 | + version-tag: ${{ github.event.inputs.tag-name }} |
| 33 | + |
| 34 | + - name: Check format of received from tag |
| 35 | + if: ${{ github.event.inputs.from-tag-name }} |
| 36 | + id: check-version-from-tag |
| 37 | + |
| 38 | + env: |
| 39 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 40 | + with: |
| 41 | + github-repository: ${{ github.repository }} |
| 42 | + version-tag: ${{ github.event.inputs.from-tag-name }} |
| 43 | + should-exist: true |
| 44 | + |
| 45 | + - name: Generate Release Notes |
| 46 | + id: generate_release_notes |
| 47 | + |
| 48 | + env: |
| 49 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 50 | + with: |
| 51 | + tag-name: ${{ github.event.inputs.tag-name }} |
| 52 | + from-tag-name: ${{ github.event.inputs.from-tag-name }} |
| 53 | + chapters: | |
| 54 | + - { title: No entry 🚫, label: duplicate } |
| 55 | + - { title: Breaking Changes 💥, label: breaking-change } |
| 56 | + - { title: New Features 🎉, label: enhancement } |
| 57 | + - { title: New Features 🎉, label: feature } |
| 58 | + - { title: Bugfixes 🛠, label: bug } |
| 59 | + - { title: Infrastructure ⚙️, label: infrastructure } |
| 60 | + - { title: Silent-live 🤫, label: silent-live } |
| 61 | + - { title: Documentation 📜, label: documentation } |
| 62 | + warnings: true |
| 63 | + |
| 64 | + - name: Create and Push Tag |
| 65 | + uses: actions/github-script@v7 |
| 66 | + with: |
| 67 | + script: | |
| 68 | + const tag = core.getInput('tag-name') |
| 69 | + const ref = `refs/tags/${tag}`; |
| 70 | + const sha = context.sha; // The SHA of the commit to tag |
| 71 | +
|
| 72 | + await github.rest.git.createRef({ |
| 73 | + owner: context.repo.owner, |
| 74 | + repo: context.repo.repo, |
| 75 | + ref: ref, |
| 76 | + sha: sha |
| 77 | + }); |
| 78 | +
|
| 79 | + console.log(`Tag created: ${tag}`); |
| 80 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 81 | + tag-name: ${{ github.event.inputs.tag-name }} |
| 82 | + |
| 83 | + - name: Create Draft Release |
| 84 | + uses: softprops/action-gh-release@v1 |
| 85 | + env: |
| 86 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 87 | + with: |
| 88 | + name: ${{ github.event.inputs.tag-name }} |
| 89 | + body: ${{ steps.generate_release_notes.outputs.release-notes }} |
| 90 | + tag_name: ${{ github.event.inputs.tag-name }} |
| 91 | + draft: true |
| 92 | + prerelease: false |
0 commit comments