magic_hour 0.76.0

Magic Hour Rust SDK
Documentation
name: Create Release

on:
  pull_request:
    types: [closed]
    branches:
      - main

jobs:
  check-and-release:
    if: github.event.pull_request.merged == true
    runs-on: blacksmith-2vcpu-ubuntu-2404
    permissions:
      contents: write
    steps:
      - name: Generate a token
        id: app-token
        uses: actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547 # v1.12.0
        with:
          app-id: 1057549 # https://github.com/organizations/magichourhq/settings/apps/magic-hour-sdk-bot
          private-key: ${{ secrets.SDK_GENERATOR_APP_PRIVATE_KEY }}

      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          fetch-depth: 2

      - name: Check if Cargo.toml version changed
        id: check_version
        run: |
          git fetch origin ${{ github.base_ref }}
          OLD_VERSION=$(git show HEAD~1:Cargo.toml | grep -m 1 '^version = ' | cut -d '"' -f 2)
          NEW_VERSION=$(grep -m 1 '^version = ' Cargo.toml | cut -d '"' -f 2)
          if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then
            echo "version_changed=true" >> $GITHUB_OUTPUT
            echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
          fi

      - name: Create Release
        if: steps.check_version.outputs.version_changed == 'true'
        uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
        with:
          tag_name: v${{ steps.check_version.outputs.new_version }}
          name: v${{ steps.check_version.outputs.new_version }}
          generate_release_notes: true
          draft: false
        env:
          GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}