|
| 1 | +# This workflow will begin a new release on Github |
| 2 | +# It will create release and pre-release branches for the repository, with the major.minor version specified |
| 3 | + |
| 4 | +name: Start new Keyfactor release |
| 5 | + |
| 6 | +on: |
| 7 | +# action runs only on manual dispatch, requries version # input |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + version: |
| 11 | + description: 'Release Version (major.minor)' |
| 12 | + required: true |
| 13 | + default: '0.0' |
| 14 | + |
| 15 | +jobs: |
| 16 | + create_branches: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + # only run on main branch |
| 19 | + if: ${{ github.ref == 'refs/heads/main' }} |
| 20 | + env: |
| 21 | + version: ${{ github.event.inputs.version }} |
| 22 | + steps: |
| 23 | + - name: GitHub Script creates branches |
| 24 | + |
| 25 | + with: |
| 26 | + script: | |
| 27 | + // get latest commit hash on main |
| 28 | + const commits = await github.repos.listCommits({ |
| 29 | + owner: context.repo.owner, |
| 30 | + repo: context.repo.repo |
| 31 | + }); |
| 32 | + const sha = commits.data[0].sha; |
| 33 | +
|
| 34 | + // create release branch |
| 35 | + const { version } = process.env; |
| 36 | + await github.git.createRef({ |
| 37 | + owner: context.repo.owner, |
| 38 | + repo: context.repo.repo, |
| 39 | + ref: `refs/heads/release-${version}`, |
| 40 | + sha: sha |
| 41 | + }); |
| 42 | +
|
| 43 | + // create pre-release branch |
| 44 | + await github.git.createRef({ |
| 45 | + owner: context.repo.owner, |
| 46 | + repo: context.repo.repo, |
| 47 | + ref: `refs/heads/release-${version}-pre`, |
| 48 | + sha: sha |
| 49 | + }); |
0 commit comments