diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index e77435ba0..aff34b364 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,8 +1,25 @@ +name-template: '$RESOLVED_VERSION' +tag-template: '$RESOLVED_VERSION' +change-template: '- #$NUMBER - $TITLE (@$AUTHOR)' categories: - - title: "⬆️ Dependencies" + - title: "⚠ Breaking Changes" + labels: + - 'breaking-change' + - title: '⬆️ Dependencies' collapse-after: 1 labels: - - "dependencies" + - 'dependencies' + - 'ci' template: | - ## What's Changed + ## What’s Changed + $CHANGES +version-resolver: + major: + labels: + - 'breaking-change' + minor: + labels: + - 'new-feature' + - 'enhancement' + default: patch diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml deleted file mode 100644 index 636630237..000000000 --- a/.github/workflows/docker-build.yml +++ /dev/null @@ -1,76 +0,0 @@ -name: Build multiarch Docker image - -on: - release: - types: [published] - workflow_dispatch: - inputs: - logLevel: - description: 'Log level' - required: true - default: 'warning' - tag: - description: 'Tag to set on docker image (e.g. 0.0.1' - required: true - -jobs: - buildx: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Prepare - id: prep - run: | - DOCKER_IMAGE=ghcr.io/music-assistant/server - VERSION=latest - SHORTREF=${GITHUB_SHA::8} - MANUAL_TAG=${{ github.event.inputs.tag }} - - # If a manual tag was supplied, use that - if [[ -n $MANUAL_TAG ]]; then - VERSION=${MANUAL_TAG} - - # If this is git tag, use the tag name as a docker tag - elif [[ $GITHUB_REF == refs/tags/* ]]; then - VERSION=${GITHUB_REF#refs/tags/} - fi - TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${SHORTREF}" - - # If the VERSION looks like a version number, assume that - # this is the most recent version of the image and also - # tag it 'latest'. - if [[ $VERSION =~ [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} ]]; then - TAGS="$TAGS,${DOCKER_IMAGE}:latest" - fi - - # Set output parameters. - echo ::set-output name=tags::${TAGS} - echo ::set-output name=docker_image::${DOCKER_IMAGE} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - with: - platforms: all - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - - - name: Log in to the Github Container registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v4 - with: - builder: ${{ steps.buildx.outputs.name }} - context: . - file: ./Dockerfile - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.prep.outputs.tags }} diff --git a/.github/workflows/pr-labels.yaml b/.github/workflows/pr-labels.yaml new file mode 100644 index 000000000..19fa0da9a --- /dev/null +++ b/.github/workflows/pr-labels.yaml @@ -0,0 +1,23 @@ +--- +name: PR Labels + +# yamllint disable-line rule:truthy +on: + pull_request: + types: + - synchronize + - labeled + - unlabeled + branches: + - main + +jobs: + pr_labels: + name: Verify + runs-on: ubuntu-latest + steps: + - name: 🏷 Verify PR has a valid label + uses: ludeeus/action-require-labels@1.0.0 + with: + labels: >- + breaking-change, bugfix, refactor, new-feature, maintenance, ci, dependencies, new-provider diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml deleted file mode 100644 index 301857fd1..000000000 --- a/.github/workflows/publish-to-pypi.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Publish releases to PyPI - -on: - release: - types: [published] - -jobs: - build-and-publish: - name: Builds and publishes releases to PyPI - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3.3.0 - - name: Set up Python 3.10 - uses: actions/setup-python@v4.6.1 - with: - python-version: "3.10" - - name: Install build - run: >- - pip install build - - name: Build - run: >- - python3 -m build - - name: Publish release to PyPI - uses: pypa/gh-action-pypi-publish@v1.8.7 - with: - user: __token__ - password: ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index c3eb58fa8..20a7b2323 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -10,6 +10,6 @@ jobs: runs-on: ubuntu-latest steps: # Drafts your next Release notes as Pull Requests are merged into "master" - - uses: release-drafter/release-drafter@v5 + - uses: release-drafter/release-drafter@v5.24.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..055da372f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,87 @@ +name: Publish releases + +on: + release: + types: [published] + +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@v3.5.3 + - name: Get tag + id: vars + run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + - name: Set up Python 3.10 + uses: actions/setup-python@v4.6.1 + with: + python-version: "3.10" + - 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 + run: >- + python3 -m build + - name: Publish release to PyPI + uses: pypa/gh-action-pypi-publish@v1.8.7 + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN }} + + build-and-push-container-image: + name: Builds and pushes the Music Assistant Server container to ghcr.io + runs-on: ubuntu-latest + permissions: + packages: write + needs: build-and-publish-pypi + steps: + - uses: actions/checkout@v3.5.3 + - name: Log in to the GitHub container registry + uses: docker/login-action@v2.2.0 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2.8.0 + - 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 + if [[ $string =~ "b" ]]; then + echo "channel=beta" >> $GITHUB_OUTPUT + else + echo "channel=stable" >> $GITHUB_OUTPUT + fi + - name: Build and Push + uses: docker/build-push-action@v4.1.1 + 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:${{ steps.tags.outputs.channel }} + push: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e955b7f8b..3dc02af31 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,13 +16,15 @@ jobs: steps: - name: Check out code from GitHub - uses: actions/checkout@v3.3.0 + uses: actions/checkout@v3.5.3 - name: Set up Python uses: actions/setup-python@v4.6.1 with: python-version: "3.11" - name: Install dependencies run: | + sudo apt-get update + sudo apt-get install -y ffmpeg python -m pip install --upgrade pip build setuptools pip install . .[test] - name: Lint/test with pre-commit @@ -39,7 +41,7 @@ jobs: steps: - name: Check out code from GitHub - uses: actions/checkout@v3.3.0 + uses: actions/checkout@v3.5.3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4.6.1 with: