π Fix upload and download articaft GH actions #289
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: Build package & publish | |
on: | |
push: | |
# Sequence of patterns matched against refs/heads | |
branches: | |
- "**" # Push events on all branchs | |
tags: | |
- v* # Push events with tags starting with v | |
jobs: | |
publish: | |
name: Build package | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
deployments: write | |
contents: write | |
statuses: write | |
actions: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: "18.x" | |
- name: Install node requirements | |
run: npm ci | |
- name: π¨ Check lint | |
run: | | |
npm run lint | |
- name: π Build html | |
run: make build | |
env: | |
BASE_PATH: /muse | |
- name: π Deploy to GitHub pages | |
if: startsWith(github.event.ref, 'refs/tags') || github.ref == 'refs/heads/master' | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} | |
publish_branch: gh-pages | |
publish_dir: ./build | |
force_orphan: true | |
- name: π Build Python package | |
run: make build-python | |
#- name: Publish package π¦ to Test PyPI | |
# uses: pypa/gh-action-pypi-publish@release/v1 | |
# if: startsWith(github.event.ref, 'refs/tags') | |
# with: | |
# repository-url: https://test.pypi.org/legacy/ | |
#- name: Publish package π¦ to PyPI | |
# uses: pypa/gh-action-pypi-publish@release/v1 | |
# if: startsWith(github.event.ref, 'refs/tags') | |
- name: π³ Docker metadata | |
id: meta | |
uses: docker/metadata-action@v4 | |
if: startsWith(github.event.ref, 'refs/tags') | |
with: | |
images: cristianpb/mopidy-muse | |
tags: | | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
if: startsWith(github.event.ref, 'refs/tags') | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
if: startsWith(github.event.ref, 'refs/tags') | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
if: startsWith(github.event.ref, 'refs/tags') | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
- name: Build and export to Docker | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
load: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
target: prod | |
build-args: | | |
app_path=/muse | |
- name: Build and push docker image | |
uses: docker/build-push-action@v5 | |
if: startsWith(github.event.ref, 'refs/tags') | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
platforms: linux/amd64,linux/arm64,linux/arm/v7 | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
target: prod | |
build-args: | | |
app_path=/muse | |
- name: π± Upload package artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Mopidy-Muse | |
path: dist/* | |
- name: β¬ Upgrade package version files | |
if: startsWith(github.event.ref, 'refs/tags') | |
run: | | |
git config --global user.name 'Github Bot' | |
git config --global user.email 'bot@github.com' | |
git add package.json package-lock.json pyproject.toml | |
git commit -m "β¬ Upgrade package version files" | |
git push origin HEAD:master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
releasing: | |
name: Publish release | |
needs: publish | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
deployments: write | |
contents: write | |
statuses: write | |
actions: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: β¬ Download artifact from build package job | |
uses: actions/download-artifact@v4 | |
with: | |
path: Mopidy-Muse | |
pattern: Mopidy-Muse | |
merge-multiple: true | |
- run: ls -R Mopidy-Muse | |
- name: πPublish Release | |
if: startsWith(github.event.ref, 'refs/tags') | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: ./Mopidy-Muse.tar.gz | |
name: Release ${{ github.ref_name }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |