π³ Sync docker version with tags #226
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 | |
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 | |
- 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@master | |
# if: startsWith(github.event.ref, 'refs/tags') | |
# with: | |
# user: __token__ | |
# password: ${{ secrets.test_pypi_password }} | |
# 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') | |
with: | |
user: __token__ | |
password: ${{ secrets.pypi_password }} | |
repository_url: https://upload.pypi.org/legacy/ | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
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 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 | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
target: prod | |
- name: π± Upload package artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Mopidy-Muse.zip | |
path: dist/Mopidy-Muse*.tar.gz | |
- 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 setup.cfg | |
git commit -m "β¬ Upgrade package version files" | |
git push origin HEAD:master | |
releasing: | |
name: Publish release | |
needs: publish | |
runs-on: ubuntu-latest | |
if: startsWith(github.event.ref, 'refs/tags') | |
steps: | |
- uses: actions/checkout@v4 | |
- name: β¬ Download artifact from build package job | |
uses: actions/download-artifact@v4 | |
with: | |
name: Mopidy-Muse.zip | |
- run: mv Mopidy-Muse*.tar.gz Mopidy-Muse.tar.gz | |
- name: πPublish Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: ./Mopidy-Muse.tar.gz | |
name: Release ${{ github.ref_name }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |