|
| 1 | +# This is a basic workflow that is manually triggered |
| 2 | + |
| 3 | +name: Release the Kraken! 🐙 |
| 4 | + |
| 5 | +# Controls when the action will run. Workflow runs when manually triggered using the UI |
| 6 | +# or API. |
| 7 | +on: |
| 8 | + workflow_dispatch: |
| 9 | + # Inputs the workflow accepts. |
| 10 | + inputs: |
| 11 | + release_type: |
| 12 | + # Release type |
| 13 | + description: 'Release type, major | minor | patch' |
| 14 | + default: 'minor' |
| 15 | + |
| 16 | + required: true |
| 17 | + |
| 18 | +# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
| 19 | +jobs: |
| 20 | + # This workflow contains a single job called "greet" |
| 21 | + release: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + # The type of runner that the job will run on |
| 24 | + |
| 25 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 26 | + steps: |
| 27 | + # Runs a single command using the runners shell |
| 28 | + - name: Checkout |
| 29 | + uses: actions/checkout@v2 |
| 30 | + - name: 'Determine Release Type' |
| 31 | + run: | |
| 32 | + if ${{ contains(github.event.inputs.release_type, 'major') }}; then |
| 33 | + echo "RELEASE_TYPE=major" >> $GITHUB_ENV |
| 34 | + elif ${{ contains(github.event.inputs.release_type, 'minor') }}; then |
| 35 | + echo "RELEASE_TYPE=minor" >> $GITHUB_ENV |
| 36 | + elif ${{ contains(github.event.inputs.release_type, 'patch') }}; then |
| 37 | + echo "RELEASE_TYPE=patch" >> $GITHUB_ENV |
| 38 | + else |
| 39 | + echo "NOTE: There was no release type specified in the commit message, and therefore no release will be published." |
| 40 | + exit 1 |
| 41 | + fi |
| 42 | + - name: 'Release Type' |
| 43 | + run: echo ${{ env.RELEASE_TYPE }} |
| 44 | + - name: git config |
| 45 | + run: | |
| 46 | + git config user.name ${{ github.actor }} |
| 47 | + # See: https://github.com/actions/cache/blob/main/examples.md#node---yarn |
| 48 | + - name: Get Yarn cache directory |
| 49 | + id: yarn-cache-dir-path |
| 50 | + run: echo "::set-output name=dir::$(yarn cache dir)" |
| 51 | + |
| 52 | + - name: Use Yarn cache |
| 53 | + uses: actions/cache@v2 |
| 54 | + id: yarn-cache |
| 55 | + with: |
| 56 | + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 57 | + key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }} |
| 58 | + |
| 59 | + - name: Install dependencies |
| 60 | + run: yarn install --prefer-offline --frozen-lockfile |
| 61 | + |
| 62 | + - name: release version |
| 63 | + run: npm run release -- ${{ env.RELEASE_TYPE }} --ci |
| 64 | + env: |
| 65 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 66 | + - name: Merge dev -> main |
| 67 | + uses: devmasx/merge-branch@master |
| 68 | + with: |
| 69 | + type: now |
| 70 | + from_branch: dev |
| 71 | + target_branch: main |
| 72 | + github_token: ${{ github.token }} |
0 commit comments