name: Release
on:
  push:
    tags:
      - "*"
jobs:
  release:
    runs-on: macos-latest
    permissions:
      contents: write
    env:
      phpVer: "8.2"
      tools: composer
      ini-values: default_charset='UTF-8'
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ env.phpVer }}
          ini-values: ${{ env.ini-values }}
          tools: ${{ env.tools }}
        env:
          fail-fast: true
      - name: Install dependencies
        run: composer install --no-progress
      - name: Get humbug/box
        uses: robinraju/
[email protected]
        with:
          repository: "box-project/box"
          latest: true
          fileName: "box.phar"
      - name: Compile wordle-cli.phar
        run: php box.phar compile
      - name: Import GPG key
        uses: crazy-max/ghaction-import-gpg@v5
        with:
          gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
          passphrase: ${{ secrets.GPG_PASSPHRASE }}
      - name: Sign wordle-cli.phar
        run: gpg -ab wordle-cli.phar
      - name: Download micro.sfx
        uses: robinraju/
[email protected]
        with:
          repository: "xrdebug/xrdebug-micro"
          out-file-path: "downloads"
          fileName: "php-*.tar.gz"
          latest: true
          tarBall: true
          extract: false
      - name: Extract micro files
        run: |
          for filename in downloads/php-*.tar.gz; do tar -xvf $filename; done
          ls micro
      - name: Cat micro
        run: ./cat.sh
      - name: Create macOS package
        run: |
          pkgbuild --identifier org.rodber.wordle-cli.pkg \
            --install-location ./usr/local/bin/ \
            --version ${{ github.ref_name}} \
            --root ./bin/macos/arm64 \
            wordle-cli-macos-arm64.pkg
          pkgbuild --identifier org.rodber.wordle-cli.pkg \
            --install-location ./usr/local/bin/ \
            --version ${{ github.ref_name}} \
            --root ./bin/macos/x86_64 \
            wordle-cli-macos-x86_64.pkg
      - name: Build Linux tar
        run: |
          tar -C bin/linux/aarch64 -zcvf wordle-cli-linux-aarch64.tar.gz wordle-cli
          tar -C bin/linux/x86_64 -zcvf wordle-cli-linux-x86_64.tar.gz wordle-cli
          ls .
      - name: Upload artifacts
        uses: ncipollo/release-action@v1
        with:
          allowUpdates: true
          artifacts: >
            wordle-cli.phar,
            wordle-cli.phar.asc,
            wordle-cli-macos-*.pkg,
            wordle-cli-linux-*.tar.gz
          token: ${{ secrets.GITHUB_TOKEN }}