Add dev manual build (#1632)
authorJozef Kruszynski <60214390+jozefKruszynski@users.noreply.github.com>
Sat, 31 Aug 2024 10:51:56 +0000 (12:51 +0200)
committerGitHub <noreply@github.com>
Sat, 31 Aug 2024 10:51:56 +0000 (12:51 +0200)
.github/workflows/release.yml
Dockerfile

index e892832423c4b3b170bceabbe9caa599908b9761..28db3366a360620e7a20b03b7da67b726d37071a 100644 (file)
@@ -3,12 +3,18 @@ name: Publish releases
 on:
   release:
     types: [published]
+  workflow_dispatch:
+    inputs:
+      tags:
+        description: 'Run Dev Build'
+        required: true
+        type: boolean
 env:
   PYTHON_VERSION: "3.11"
 
 jobs:
-  build-and-publish-pypi:
-    name: Builds and publishes releases to PyPI
+  build-artifact:
+    name: Builds python artifact uploads to Github Artifact store
     runs-on: ubuntu-latest
     outputs:
       version: ${{ steps.vars.outputs.tag }}
@@ -16,20 +22,29 @@ jobs:
       - 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
+          if [[ "${{ inputs.tags }}" == "true" ]]; then
+            echo "tag=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_OUTPUT
           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
+            echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
+          fi  
+      - name: Validate version number
+        run: >-
+          if [[ "${{ inputs.tags }}" == "true" ]]; then
+            echo "Skipping version validation for manual trigger"
+          else  
+            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
-          fi
+          fi  
       - name: Set up Python ${{ env.PYTHON_VERSION }}
         uses: actions/setup-python@v5.2.0
         with:
@@ -53,6 +68,23 @@ jobs:
       - name: Build python package
         run: >-
           python3 -m build
+      - name: Upload distributions
+        uses: actions/upload-artifact@v4
+        with:
+          name: release-dists
+          path: dist/
+      
+  pypi-publish:
+    runs-on: ubuntu-latest
+    if: ${{ ! inputs.tags }}
+    needs:
+      - build-artifact
+    steps:
+      - name: Retrieve release distributions
+        uses: actions/download-artifact@v4
+        with:
+          name: release-dists
+          path: dist/
       - name: Publish release to PyPI
         uses: pypa/gh-action-pypi-publish@v1.9.0
         with:
@@ -66,8 +98,13 @@ jobs:
     runs-on: ubuntu-latest
     permissions:
       packages: write
-    needs: build-and-publish-pypi
+    needs: build-artifact
     steps:
+      - name: Retrieve release distributions
+        uses: actions/download-artifact@v4
+        with:
+          name: release-dists
+          path: dist/
       - uses: actions/checkout@v4.1.4
       - name: Download Widevine CDM client files from private repository
         shell: bash
@@ -95,7 +132,7 @@ jobs:
           echo "major=${patch%.*.*}" >> $GITHUB_OUTPUT
       - name: Build and Push release
         uses: docker/build-push-action@v6.7.0
-        if: github.event.release.prerelease == false
+        if: ${{ ! inputs.tags && github.event.release.prerelease == false }}
         with:
           context: .
           platforms: linux/amd64,linux/arm64
@@ -107,10 +144,10 @@ jobs:
             ghcr.io/${{ github.repository_owner }}/server:stable,
             ghcr.io/${{ github.repository_owner }}/server:latest
           push: true
-          build-args: "MASS_VERSION=${{ needs.build-and-publish-pypi.outputs.version }}"
+          build-args: "MASS_VERSION=${{ needs.build-artifact.outputs.version }}"
       - name: Build and Push pre-release
         uses: docker/build-push-action@v6.7.0
-        if: github.event.release.prerelease == true
+        if: ${{ ! inputs.tags && github.event.release.prerelease == true }}
         with:
           context: .
           platforms: linux/amd64,linux/arm64
@@ -119,25 +156,41 @@ jobs:
             ghcr.io/${{ github.repository_owner }}/server:${{ steps.tags.outputs.patch }},
             ghcr.io/${{ github.repository_owner }}/server:beta
           push: true
-          build-args: "MASS_VERSION=${{ needs.build-and-publish-pypi.outputs.version }}"
+          build-args: "MASS_VERSION=${{ needs.build-artifact.outputs.version }}"
+      - name: Build and Push dev-release
+        uses: docker/build-push-action@v6.7.0
+        if: inputs.tags
+        with:
+          context: .
+          platforms: linux/amd64,linux/arm64
+          file: Dockerfile
+          tags: |-
+            ghcr.io/${{ github.repository_owner }}/server:${{ needs.build-artifact.outputs.version }},
+            ghcr.io/${{ github.repository_owner }}/server:dev
+          push: true
+          build-args: |
+            MASS_VERSION=${{ needs.build-artifact.outputs.version }}
+            DEV_RELEASE="true"
+            MASS_INSTALL_LOCATION="/tmp/music_assitant-${{ needs.build-artifact.outputs.version }}-py3-none-any.whl"
 
   release-notes-update:
     name: Updates the release notes and changelog
-    needs: [build-and-publish-pypi, build-and-push-container-image]
+    needs: [build-artifact, pypi-publish, build-and-push-container-image]
     runs-on: ubuntu-latest
     steps:
       - name: Update changelog and release notes including frontend notes
         uses: music-assistant/release-notes-merge-action@main
         with:
           github_token: ${{ secrets.PRIVILEGED_GITHUB_TOKEN }}
-          release_tag: ${{ needs.build-and-publish-pypi.outputs.version }}
+          release_tag: ${{ needs.build-artifact.outputs.version }}
           pre_release: ${{ github.event.release.prerelease }}
 
   addon-version-update:
     name: Updates the Addon repository with the new version
     needs:
       [
-        build-and-publish-pypi,
+        build-artifact,  
+        pypi-publish,
         build-and-push-container-image,
         release-notes-update,
       ]
@@ -147,5 +200,5 @@ jobs:
         uses: music-assistant/addon-update-action@main
         with:
           github_token: ${{ secrets.PRIVILEGED_GITHUB_TOKEN }}
-          new_server_version: ${{ needs.build-and-publish-pypi.outputs.version }}
+          new_server_version: ${{ needs.build-artifact.outputs.version }}
           pre_release: ${{ github.event.release.prerelease }}
index 7dce44d2202df8cfde0f47c11d7de7dc72b3cb04..704782265f8d65caebea488dcb2fff4727900441 100644 (file)
@@ -4,6 +4,8 @@ FROM python:3.12-alpine3.20
 
 ARG MASS_VERSION
 ARG TARGETPLATFORM
+ARG DEV_RELEASE="false"
+ARG MASS_INSTALL_LOCATION="music-assistant[server]==${MASS_VERSION}"
 
 RUN set -x \
     && apk add --no-cache \
@@ -27,6 +29,9 @@ RUN set -x \
 # Copy widevine client files to container
 RUN mkdir -p /usr/local/bin/widevine_cdm
 COPY widevine_cdm/* /usr/local/bin/widevine_cdm/
+COPY dist/music_assitant-${MASS_VERSION}-py3-none-any.whl /tmp/
+
+RUN bash -c 'if [ "${DEV_RELEASE}" = "false" ]; then rm /tmp/music_assitant-${MASS_VERSION}-py3-none-any.whl; fi'
 
 # Upgrade pip + Install uv
 RUN pip install --upgrade pip \
@@ -37,7 +42,7 @@ RUN uv pip install \
     --system \
     --no-cache \
     --find-links "https://wheels.home-assistant.io/musllinux/" \
-    music-assistant[server]==${MASS_VERSION}
+    ${MASS_INSTALL_LOCATION}
 
 # Configure runtime environmental variables
 ENV LD_PRELOAD="/usr/lib/libjemalloc.so.2"