nimblehq / ios-templates

Our optimized iOS templates used in our projects
https://nimblehq.co
MIT License
85 stars 13 forks source link

Automate Release Pull Request Creation Process #557

Open nkhanh44 opened 2 months ago

nkhanh44 commented 2 months ago

Why

We can improve the workflow by automating the process of creating release pull requests, including building the changelog, creating a release branch, and creating the pull request. This will streamline the process and make it more efficient for the team.

Acceptance Criteria

Example:

create_release_pull_request.yml

name: Create Release Pull Request

on:
  workflow_dispatch:
    inputs:
      newVersion:
        description: "Version name"
        required: true
        type: string

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  create_release_pull_request:
    name: Create Release Pull Request
    runs-on: ubuntu-latest
    timeout-minutes: 30
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Find HEAD commit
        id: head
        run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT

      - name: Build changelog
        id: changelog
        uses: mikepenz/release-changelog-builder-action@v4
        with:
          configuration: ".github/workflows/configs/changelog-config.json"
          toTag: ${{ steps.head.outputs.sha }}
          token: ${{ secrets.GITHUB_TOKEN }}

      - name: Create Release branch
        uses: peterjgrainger/action-create-branch@v2.2.0
        with:
          branch: release/${{ github.event.inputs.newVersion }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Create pull request
        run: gh pr create --draft -B main -H release/${{ github.event.inputs.newVersion }} -t 'Release - ${{ github.event.inputs.newVersion }}' -b "${{ steps.changelog.outputs.changelog }}"
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

changelog-config.json

{
  "categories": [
    {
      "title": "## ✨ Features",
      "labels": [
        "type : feature"
      ]
    },
    {
      "title": "## 🐛 Bug fixes",
      "labels": [
        "type : bug"
      ]
    },
    {
      "title": "## 🧹 Chores",
      "labels": [
        "type : chore"
      ]
    },
    {
      "title": "## Others",
      "exclude_labels": [
        "type : feature",
        "type : bug",
        "type : chore",
        "type : release"
      ]
    }
  ],
  "max_pull_requests": 200
}

Who Benefits?

markgravity commented 2 months ago

@nkhanh44 I can work on it 🙏