ci: 🎡 Ensure to download artifacts during docker jobs #186
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] | ||
workflow_dispatch: | ||
env: | ||
PYTHON_VERSION: "3.11" | ||
jobs: | ||
build-artifact: | ||
name: Builds python artifact uploads to Github Artifact store | ||
runs-on: ubuntu-latest | ||
outputs: | ||
version: ${{ steps.vars.outputs.tag }} | ||
steps: | ||
- uses: actions/checkout@v4.1.4 | ||
- name: Get tag | ||
id: vars | ||
run: | ||
if [[ "${{ github.event.workflow_dispatch }}" == "true" ]]; then | ||
echo "tag=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_OUTPUT | ||
else | ||
echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Validate version number | ||
run: >- | ||
if [[ "${{ github.event.workflow_dispatch }}" == "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 | ||
- name: Set up Python ${{ env.PYTHON_VERSION }} | ||
uses: actions/setup-python@v5.2.0 | ||
with: | ||
python-version: ${{ env.PYTHON_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 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: !github.event.workflow_dispatch | ||
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: | ||
user: __token__ | ||
password: ${{ secrets.PYPI_TOKEN }} | ||
- name: Wait for PyPI | ||
run: sleep 300 | ||
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-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 | ||
env: | ||
TOKEN: ${{ secrets.PRIVILEGED_GITHUB_TOKEN }} | ||
run: | | ||
mkdir -p widevine_cdm && cd widevine_cdm | ||
curl -OJ -H "Authorization: token ${TOKEN}" https://raw.githubusercontent.com/music-assistant/appvars/main/widevine_cdm_client/private_key.pem | ||
curl -OJ -H "Authorization: token ${TOKEN}" https://raw.githubusercontent.com/music-assistant/appvars/main/widevine_cdm_client/client_id.bin | ||
- 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.7.0 | ||
if: !github.event.workflow_dispatch && github.event.release.prerelease == false | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64 | ||
file: Dockerfile | ||
tags: |- | ||
ghcr.io/${{ github.repository_owner }}/server:${{ steps.tags.outputs.patch }}, | ||
ghcr.io/${{ github.repository_owner }}/server:${{ steps.tags.outputs.minor }}, | ||
ghcr.io/${{ github.repository_owner }}/server:${{ steps.tags.outputs.major }}, | ||
ghcr.io/${{ github.repository_owner }}/server:stable, | ||
ghcr.io/${{ github.repository_owner }}/server:latest | ||
push: true | ||
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.workflow_dispatch && github.event.release.prerelease == true | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64 | ||
file: Dockerfile | ||
tags: |- | ||
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-artifact.outputs.version }}" | ||
- name: Build and Push dev-release | ||
uses: docker/build-push-action@v6.7.0 | ||
if: github.event.workflow_dispatch == true | ||
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-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-artifact.outputs.version }} | ||
pre_release: ${{ github.event.release.prerelease }} | ||
addon-version-update: | ||
name: Updates the Addon repository with the new version | ||
needs: | ||
[ | ||
build-artifact, | ||
pypi-publish, | ||
build-and-push-container-image, | ||
release-notes-update, | ||
] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Push new version number to addon config | ||
uses: music-assistant/addon-update-action@main | ||
with: | ||
github_token: ${{ secrets.PRIVILEGED_GITHUB_TOKEN }} | ||
new_server_version: ${{ needs.build-artifact.outputs.version }} | ||
pre_release: ${{ github.event.release.prerelease }} |