m2s2-cli 0.1.21

CLI for scaffolding M²S² design system projects
name: Release

on:
  workflow_run:
    workflows: ["CI"]
    branches: [main]
    types: [completed]

jobs:
  release:
    if: ${{ github.event.workflow_run.conclusion == 'success' }}
    runs-on: ubuntu-22.04
    permissions:
      contents: write
      pull-requests: write
    steps:
      - uses: actions/create-github-app-token@v1
        id: app-token
        with:
          app-id: ${{ secrets.APP_ID }}
          private-key: ${{ secrets.APP_PRIVATE_KEY }}

      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
          token: ${{ steps.app-token.outputs.token }}

      - uses: dtolnay/rust-toolchain@stable

      - name: Install release-plz
        uses: taiki-e/install-action@v2
        with:
          tool: release-plz

      - name: Bump version
        id: bump
        run: |
          release-plz update
          if git diff --quiet; then
            echo "changed=false" >> "$GITHUB_OUTPUT"
          else
            VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
            echo "changed=true" >> "$GITHUB_OUTPUT"
            echo "version=$VERSION" >> "$GITHUB_OUTPUT"
          fi

      - name: Commit and push tag
        if: steps.bump.outputs.changed == 'true'
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add Cargo.toml Cargo.lock CHANGELOG.md
          git commit -m "chore(release): v${{ steps.bump.outputs.version }} [skip ci]"
          git tag "v${{ steps.bump.outputs.version }}"
          git push origin HEAD:main --tags
        env:
          GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}