6.6.1 #104
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish releases | |
on: | |
release: | |
types: [published] | |
env: | |
PYTHON_VERSION: "3.11" | |
NODE_VERSION: "18.x" | |
jobs: | |
build-and-publish-pypi: | |
name: Builds and publishes releases to PyPI | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.vars.outputs.tag }} | |
steps: | |
- uses: actions/checkout@v4.2.0 | |
- name: Get tag | |
id: vars | |
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT | |
- name: Validate version number | |
run: >- | |
if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then | |
if ! [[ "${{ steps.vars.outputs.tag }}" =~ "b" ]]; then | |
echo "Pre-release: Tag is missing beta suffix (${{ steps.vars.outputs.tag }})" | |
exit 1 | |
fi | |
else | |
if [[ "${{ steps.vars.outputs.tag }}" =~ "b" ]]; then | |
echo "Release: Tag must not have a beta suffix (${{ steps.vars.outputs.tag }})" | |
exit 1 | |
fi | |
fi | |
- name: Set up Python ${{ env.PYTHON_VERSION }} | |
uses: actions/setup-python@v5.2.0 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Set up Node ${{ env.NODE_VERSION }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Install build | |
run: >- | |
pip install build tomli tomli-w | |
- name: Set Python project version from tag | |
shell: python | |
run: |- | |
import tomli | |
import tomli_w | |
with open("pyproject.toml", "rb") as f: | |
pyproject = tomli.load(f) | |
pyproject["project"]["version"] = "${{ steps.vars.outputs.tag }}" | |
with open("pyproject.toml", "wb") as f: | |
tomli_w.dump(pyproject, f) | |
- name: Build dashboard | |
run: | | |
pip install -e . | |
dashboard/script/setup | |
dashboard/script/build | |
- name: Build python package | |
run: >- | |
python3 -m build | |
- name: Publish release to PyPI | |
uses: pypa/gh-action-pypi-publish@v1.10.2 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_TOKEN }} | |
- name: Wait for PyPI | |
run: sleep 300 | |
build-and-push-container-image: | |
name: Builds and pushes the Matter Server container to ghcr.io | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
needs: build-and-publish-pypi | |
steps: | |
- uses: actions/checkout@v4.2.0 | |
- name: Log in to the GitHub container registry | |
uses: docker/login-action@v3.3.0 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3.6.1 | |
- name: Version number for tags | |
id: tags | |
shell: bash | |
run: |- | |
patch=${GITHUB_REF#refs/*/} | |
echo "patch=${patch}" >> $GITHUB_OUTPUT | |
echo "minor=${patch%.*}" >> $GITHUB_OUTPUT | |
echo "major=${patch%.*.*}" >> $GITHUB_OUTPUT | |
- name: Build and Push release | |
uses: docker/build-push-action@v6.9.0 | |
if: github.event.release.prerelease == false | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
file: Dockerfile | |
tags: |- | |
ghcr.io/${{ github.repository_owner }}/python-matter-server:${{ steps.tags.outputs.patch }}, | |
ghcr.io/${{ github.repository_owner }}/python-matter-server:${{ steps.tags.outputs.minor }}, | |
ghcr.io/${{ github.repository_owner }}/python-matter-server:${{ steps.tags.outputs.major }}, | |
ghcr.io/${{ github.repository_owner }}/python-matter-server:stable | |
push: true | |
build-args: "PYTHON_MATTER_SERVER=${{ needs.build-and-publish-pypi.outputs.version }}" | |
- name: Build and Push pre-release | |
uses: docker/build-push-action@v6.9.0 | |
if: github.event.release.prerelease == true | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
file: Dockerfile | |
tags: |- | |
ghcr.io/${{ github.repository_owner }}/python-matter-server:${{ steps.tags.outputs.patch }}, | |
ghcr.io/${{ github.repository_owner }}/python-matter-server:beta | |
push: true | |
build-args: "PYTHON_MATTER_SERVER=${{ needs.build-and-publish-pypi.outputs.version }}" |