vinicioslc/adb-interface-vscode

View on GitHub
.github/workflows/draft-release.yml

Summary

Maintainability
Test Coverage
name: draft-new-release-version

on:
  workflow_dispatch:
    inputs:
      version:
        description: "The version you want to release. X.X.X"
        required: true

jobs:
  draft-new-release:
    name: "Create the new version PR"
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Create release branch
        run: git checkout -b release/${{ github.event.inputs.version }}

      # In order to make a commit, we need to initialize a user.
      # You may choose to write something less generic here if you want, it doesn't matter functionality wise.
      - name: Initialize mandatory git config
        run: |
          git config user.name "GitHub actions"
          git config user.email noreply@github.com

      - uses: actions/setup-node@v3
        with:
          cache: "npm"
        env:
          NODE_AUTH_TOKEN: ${{ secrets.MERGE_PAT_TOKEN }}
      - run: npm install -g npm gitmoji-changelog release-it
      - run: npm ci

      - name: Update package.json and CHANGELOG.md
        env:
          GITHUB_TOKEN: ${{ secrets.MERGE_PAT_TOKEN }}
        # npm ci skip run additional scripts after install - this remove any necessary setup.
        run: npx release-it ${{ github.event.inputs.version }} --ci

      - name: Push new branch
        run: |
          git push origin release/${{ github.event.inputs.version }}
          git status

      - name: Create pull request
        uses: thomaseizinger/create-pull-request@1.0.0
        env:
          GITHUB_TOKEN: ${{ secrets.MERGE_PAT_TOKEN }}
        with:
          head: release/${{ github.event.inputs.version }}
          base: main
          title: Release version ${{ github.event.inputs.version }}
          reviewers: ${{ github.actor }} # By default, we request a review from the person who triggered the workflow.
          # Write a nice message to the user.
          # We are claiming things here based on the `publish-new-release.yml` workflow.
          # You should obviously adopt it to say the truth depending on your release workflow :)
          body: |
            Hi @${{ github.actor }}!
            This PR was created in response to a manual trigger of the release workflow here: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}.
            I've updated the changelog with commit messages and bumped the versions in the manifest files in this commit: ${{ steps.make-commit.outputs.commit }}.
            Merging this PR will create a GitHub Release and build and deploy assets on production machine.