name: Release on: push: tags: # Publish on any tag starting with a `v`, e.g., v1.0.1 - "v*" permissions: contents: write jobs: check_version: name: Check Version runs-on: ubuntu-latest outputs: version: ${{ steps.read_version.outputs.version }} steps: - name: Checkout uses: actions/checkout@v6 - name: Install uv uses: astral-sh/setup-uv@v7 with: python-version: "3.11" - name: Check tag matches project version id: read_version run: | version="$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")" if [ "v$version" != "$GITHUB_REF_NAME" ]; then echo "Tag $GITHUB_REF_NAME does not match pyproject.toml version $version" >&2 exit 1 fi echo "version=$version" >> "$GITHUB_OUTPUT" build_extensions: name: Build Extensions needs: check_version runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v6 - name: Install uv uses: astral-sh/setup-uv@v7 with: python-version: "3.11" - name: Build node assets run: uv run --group blender node-group build --skip-tests - name: Run tests env: LIBGL_ALWAYS_SOFTWARE: "1" run: xvfb-run -a uv run --group blender pytest tests/anyimage tests/nodes tests/tools - name: Pack extensions run: uv run pack - name: Check extension archives run: | for platform in windows-x64 macos-arm64 linux-x64; do archive="dist/AnyImage.v${{ needs.check_version.outputs.version }}.${platform}.zip" if [ ! -f "$archive" ]; then echo "Missing archive: $archive" >&2 exit 1 fi done - name: Publish GitHub release if: github.server_url == 'https://github.com' env: GH_TOKEN: ${{ github.token }} run: gh release create "$GITHUB_REF_NAME" dist/*.zip --verify-tag --generate-notes - name: Publish Gitea release if: github.server_url != 'https://github.com' env: RELEASE_TOKEN: ${{ github.token }} run: | release_id="$(curl --fail-with-body \ --header "Authorization: token $RELEASE_TOKEN" \ --header "Content-Type: application/json" \ --data "$(jq -n --arg tag "$GITHUB_REF_NAME" '{tag_name: $tag, name: $tag}')" \ "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases" | jq -r .id)" for archive in dist/*.zip; do curl --fail-with-body \ --request POST \ --header "Authorization: token $RELEASE_TOKEN" \ --header "Content-Type: application/octet-stream" \ --data-binary "@$archive" \ "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/$release_id/assets?name=$(basename "$archive")" done