on: push: tags: - "v*" # Push events to matching `v*` version srings. e.g. v1.0, v20.15.10 name: Create and Publish Release jobs: check-rust-ok: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: submodules: recursive - name: Build run: cargo build --verbose - name: Check for lints run: cargo clippy - name: Run tests run: | cargo test --verbose build: name: Build Python distribution runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v2 with: submodules: recursive fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v2 with: python-version: '3.x' - name: Install release dependencies run: | python -m pip install --upgrade pip pip install --upgrade setuptools wheel build - name: Get release notes id: release_notes run: | # By default, GH Actions checkout will only fetch a single commit. # For us to extract the release notes, we need to fetch the tags # and tag annotations as well. # https://github.com/actions/checkout/issues/290 git fetch --tags --force TAG_NAME=${GITHUB_REF/refs\/tags\//} echo "$(git tag -l --format='%(contents)' $TAG_NAME)" > "${{ runner.temp }}/CHANGELOG.md" - name: Create GitHub release id: create_release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ github.ref }} release_name: ${{ github.ref }} body_path: "${{ runner.temp }}/CHANGELOG.md" draft: false prerelease: false - name: Build a binary wheel and a source tarball run: python3 -m build - name: Store the distribution packages uses: actions/upload-artifact@v4 with: name: python-package-distributions path: dist/ publish-to-pypi: name: >- Publish Python 🐍 distribution 📦 to PyPI if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes needs: - build runs-on: ubuntu-latest environment: name: pypi url: https://pypi.org/p/axisregistry permissions: id-token: write # IMPORTANT: mandatory for trusted publishing steps: - name: Download all the dists uses: actions/download-artifact@v4 with: name: python-package-distributions path: dist/ - name: Publish distribution 📦 to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: # repository-url: https://test.pypi.org/legacy/ # for testing purposes verify-metadata: false # twine previously didn't verify metadata when uploading publish-rust: name: >- Publish Rust 🦀 crate 📦 to crates.io if: startsWith(github.ref, 'refs/tags/') # only publish to crates.io on tag pushes needs: - build - check-rust-ok runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: submodules: recursive - name: Check tag version and Cargo.toml version are same run: | TAG_NAME=${GITHUB_REF/refs\/tags\//} CARGO_TOML_VERSION=$(grep -E '^version\s*=' Cargo.toml | cut -d '"' -f 2) if [ "$TAG_NAME" != "$CARGO_TOML_VERSION" ]; then echo "Tag version ($TAG_NAME) and Cargo.toml version ($CARGO_TOML_VERSION) do not match." exit 1 fi - name: Publish crate 📦 to crates.io run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} upstream-subtree-merge: name: >- Update google/fonts with a new release of axisregistry if: startsWith(github.ref, 'refs/tags/') # only merge into upstream on tag pushes needs: - build runs-on: ubuntu-latest steps: - name: Checkout google/fonts uses: actions/checkout@v3 with: repository: google/fonts token: ${{ secrets.GOOGLE_FONTS_TOKEN }} fetch-depth: 0 - name: Configure git run: | git config user.name "axisregistry-bot" git config user.email "axisregistry-bot@github.com" - name: Create branch id: branch run: | TAG_NAME="${GITHUB_REF#refs/tags/}" BRANCH_NAME="axisregistry-release-${TAG_NAME}" git checkout -b "${BRANCH_NAME}" echo "branch_name=${BRANCH_NAME}" >> "$GITHUB_OUTPUT" - name: Subtree pull from axisregistry main run: | git subtree pull \ --prefix=axisregistry \ https://github.com/googlefonts/axisregistry.git \ main - name: Push branch to google/fonts run: | git push origin "${{ steps.branch.outputs.branch_name }}" - name: Create Pull Request env: GH_TOKEN: ${{ secrets.GOOGLE_FONTS_TOKEN }} run: | TAG_NAME="${GITHUB_REF#refs/tags/}" gh pr create \ --repo google/fonts \ --base main \ --head "${{ steps.branch.outputs.branch_name }}" \ --title "Update axisregistry to ${TAG_NAME}" \ --body "This PR updates the \`axisregistry\` subtree with the latest release ($TAG_NAME) from [googlefonts/axisregistry](https://github.com/googlefonts/axisregistry). **Important:** When merging, use the **\"Create a merge commit\"** button, **not** \"Squash and merge\", to preserve subtree history and avoid future merge conflicts."