wit-bindgen-cli 0.56.0

CLI tool to generate bindings for WIT documents and the component model.
# Publication half of the release process for this repository. This runs on
# pushes to `main` and will detect a magical string in commit messages. When
# found a tag will be created, pushed, and then everything is published.

name: Publish Artifacts
on:
  push:
    branches: [main]

permissions:
  contents: write
  id-token: write

jobs:
  create_tag:
    name: Publish artifacts of build
    runs-on: ubuntu-latest
    environment: release
    if: |
      github.repository_owner == 'bytecodealliance'
      && github.event_name == 'push'
      && github.ref == 'refs/heads/main'
    steps:
    - uses: actions/checkout@v4
      with:
        submodules: true
        fetch-depth: 0

    - run: rustup update stable && rustup default stable

    # If this is a push to `main` see if the push has an indicator saying that
    # a tag should be made. If so create one and push it.
    - name: Test if tag is needed
      run: |
        git log ${{ github.event.before }}...${{ github.event.after }} | tee main.log
        version=$(./ci/print-current-version.sh)
        echo "version: $version"
        echo "version=$version" >> $GITHUB_OUTPUT
        echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
        if grep -q "automatically-tag-and-release-this-commit" main.log; then
          echo push-tag
          echo "push_tag=yes" >> $GITHUB_OUTPUT
        else
          echo no-push-tag
          echo "push_tag=no" >> $GITHUB_OUTPUT
        fi
      id: tag

    - name: Push the tag
      run: |
        git_refs_url=$(jq .repository.git_refs_url $GITHUB_EVENT_PATH | tr -d '"' | sed 's/{\/sha}//g')
        curl -iX POST $git_refs_url \
          -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
          -d @- << EOF
        {
          "ref": "refs/tags/v${{ steps.tag.outputs.version }}",
          "sha": "${{ steps.tag.outputs.sha }}"
        }
        EOF
      if: steps.tag.outputs.push_tag == 'yes'

    - name: Push Go package tag
      run: |
        git_refs_url=$(jq .repository.git_refs_url $GITHUB_EVENT_PATH | tr -d '"' | sed 's/{\/sha}//g')
        curl -iX POST $git_refs_url \
          -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
          -d @- << EOF
        {
          "ref": "refs/tags/crates/go/src/package/v${{ steps.tag.outputs.version }}",
          "sha": "${{ steps.tag.outputs.sha }}"
        }
        EOF
      if: steps.tag.outputs.push_tag == 'yes'


    - run: |
        sha=${{ github.sha }}
        run_id=$(
          gh api -H 'Accept: application/vnd.github+json' \
              /repos/${{ github.repository }}/actions/workflows/main.yml/runs\?exclude_pull_requests=true \
              | jq '.workflow_runs' \
              | jq "map(select(.head_commit.id == \"$sha\"))[0].id" \
        )
        gh run download $run_id
        ls
        find bins-*
        mkdir dist
        mv bins-*/* dist
      env:
        GH_TOKEN: ${{ github.token }}

    - if: steps.tag.outputs.push_tag == 'yes'
      run: gh release create --generate-notes v${{ steps.tag.outputs.version }} dist/*
      env:
        GH_TOKEN: ${{ github.token }}

    - uses: rust-lang/crates-io-auth-action@v1
      id: auth
      if: steps.tag.outputs.push_tag == 'yes'

    - run: |
        rm -rf dist main.log
        rustc ci/publish.rs
        ./publish publish
      env:
        CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
      if: steps.tag.outputs.push_tag == 'yes'