-
Notifications
You must be signed in to change notification settings - Fork 6
133 lines (128 loc) · 4.35 KB
/
publish.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
---
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
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
with:
skip-existing: true
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 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.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 pyproject.toml
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 }}