-
Notifications
You must be signed in to change notification settings - Fork 108
151 lines (143 loc) · 5.58 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Publish releases
on:
release:
types: [published]
env:
PYTHON_VERSION: "3.11"
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.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" ]]; 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.1.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: Publish release to PyPI
uses: pypa/gh-action-pypi-publish@v1.8.14
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-and-publish-pypi
steps:
- 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.2.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.3.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
- name: Build and Push release
uses: docker/build-push-action@v5.3.0
if: 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-and-publish-pypi.outputs.version }}"
- name: Build and Push pre-release
uses: docker/build-push-action@v5.3.0
if: 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-and-publish-pypi.outputs.version }}"
release-notes-update:
name: Updates the release notes and changelog
needs: [build-and-publish-pypi, 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 }}
pre_release: ${{ github.event.release.prerelease }}
addon-version-update:
name: Updates the Addon repository with the new version
needs:
[
build-and-publish-pypi,
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-and-publish-pypi.outputs.version }}
pre_release: ${{ github.event.release.prerelease }}