diff --git a/.github/pr-labels.yaml b/.github/pr-labels.yaml new file mode 100644 index 00000000..63ec360f --- /dev/null +++ b/.github/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.1.0 + with: + labels: >- + breaking-change, bugfix, refactor, new-feature, maintenance, ci, dependencies, documentation, enhancement diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 00000000..88b36b7a --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,42 @@ +name-template: "$RESOLVED_VERSION" +tag-template: "$RESOLVED_VERSION" +change-template: "- #$NUMBER - $TITLE (@$AUTHOR)" +categories: + - title: "⚠ Breaking Changes" + labels: + - "breaking-change" + + - title: "🐛 Bugfixes" + labels: + - "bugfix" + + - title: "🚀 Features" + labels: + - "feature" + - "enhancement" + - "new-feature" + + - title: "🧰 Maintenance" + labels: + - "ci" + - "documentation" + - "maintenance" + + - title: "⬆️ Dependencies" + collapse-after: 1 + labels: + - "dependencies" + +template: | + ## What’s Changed + + $CHANGES + +version-resolver: + major: + labels: + - "breaking-change" + minor: + labels: + - "new-feature" + default: patch diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 72c90c34..af05d975 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -5,98 +5,11 @@ on: branches: - main -permissions: - contents: write - pull-requests: write - jobs: - release-please: - runs-on: ubuntu-latest - outputs: - version: ${{ steps.release.outputs.tag_name }} - release_created: ${{ steps.release.outputs.release_created }} - steps: - - uses: googleapis/release-please-action@v4 - id: release - with: - # this assumes that you have created a personal access token - # (PAT) and configured it as a GitHub action secret named - # `MY_RELEASE_PLEASE_TOKEN` (this secret name is not important). - token: ${{ secrets.GITHUB_TOKEN }} - # this is a built-in strategy in release-please, see "Action Inputs" - # for more options - release-type: simple - - build-release-artifact: - name: Build Release Artifact - needs: release-please - if: ${{ needs.release-please.outputs.release_created }} + update_release_draft: runs-on: ubuntu-latest - env: - version: ${{ needs.release-please.outputs.version }} - PYTHON_VERSION: "3.10" - NODE_VERSION: "18.x" - NODE_OPTIONS: --max_old_space_size=6144 steps: - - name: Checkout the repository - uses: actions/checkout@v4 - - - name: Get tag - id: vars - run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT - - - name: Set up Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@v5 - with: - python-version: ${{ env.PYTHON_VERSION }} - - - name: Set up Node ${{ env.NODE_VERSION }} - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODE_VERSION }} - cache: yarn - - - name: Install dependencies - run: | - yarn install - python3 -m 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"] = "${{ env.version }}" - - with open("pyproject.toml", "wb") as f: - tomli_w.dump(pyproject, f) - - - name: Build and release package - run: | - yarn build - rm -rf dist music_assistant_frontend.egg-info - python3 -m build - - - name: Publish release to PyPI - uses: pypa/gh-action-pypi-publish@v1.12.3 - with: - user: __token__ - password: ${{ secrets.PYPI_TOKEN }} - - - name: Upload release assets - uses: softprops/action-gh-release@v2.2.0 - with: - tag_name: ${{ env.version }} - files: | - dist/*.whl - dist/*.tar.gz - - - name: Create Server repo PR - uses: music-assistant/frontend-release-pr-action@main - with: - github_token: ${{ secrets.PRIVILEGED_GITHUB_TOKEN }} - new_release_version: ${{ env.version }} + # Drafts your next Release notes as Pull Requests are merged into "main" + - uses: release-drafter/release-drafter@v6.0.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..ca740146 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,92 @@ +name: Publish releases + +on: + release: + types: [published] + +env: + PYTHON_VERSION: "3.12" + NODE_VERSION: "18.x" + NODE_OPTIONS: --max_old_space_size=6144 + +jobs: + build-artifact: + name: Builds precompiled version of the frontend and release as pypi package + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4.1.4 + - 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" || "${{ steps.vars.outputs.tag }}" =~ "rc" ]]; then + echo "Pre-release: Tag is missing beta suffix (${{ steps.vars.outputs.tag }})" + exit 1 + fi + else + if [[ "${{ steps.vars.outputs.tag }}" =~ "b" || "${{ steps.vars.outputs.tag }}" =~ "rc" ]]; then + echo "Release: Tag must not have a beta (or rc) suffix (${{ steps.vars.outputs.tag }})" + exit 1 + fi + fi + - name: Set up Python ${{ env.PYTHON_VERSION }} + uses: actions/setup-python@v5.3.0 + with: + python-version: ${{ env.PYTHON_VERSION }} + - name: Install build + run: >- + pip install build tomli tomli-w + - name: Set up Node ${{ env.NODE_VERSION }} + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: yarn + + - name: Install dependencies + run: | + yarn install + python3 -m 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 and release package + run: | + yarn build + rm -rf dist music_assistant_frontend.egg-info + python3 -m build + + - name: Publish release to PyPI + uses: pypa/gh-action-pypi-publish@v1.12.3 + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN }} + + - name: Upload release assets + uses: softprops/action-gh-release@v2.2.0 + with: + tag_name: ${{ steps.vars.outputs.tag }} + files: | + dist/*.whl + dist/*.tar.gz + + - name: Create Server repo PR + uses: music-assistant/frontend-release-pr-action@main + with: + github_token: ${{ secrets.PRIVILEGED_GITHUB_TOKEN }} + new_release_version: ${{ steps.vars.outputs.tag }}