-
Notifications
You must be signed in to change notification settings - Fork 1
159 lines (147 loc) · 5.25 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Publish version
on:
push:
tags: [ '*' ]
permissions:
contents: read
env:
REGISTRY: docker.io
IMAGE_NAME: majorcadevs/mdbackup
jobs:
whl:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install wheel twine
- name: Build wheel
run: |
python setup.py sdist bdist_wheel
- name: Publish
run: |
twine upload --user ${{ secrets.PYPI_USER }} --password ${{ secrets.PYPI_PASS }} dist/*
- uses: ncipollo/release-action@v1
with:
artifacts: 'dist/*.whl'
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: ${{ contains(github.ref, 'beta') || contains(github.ref, 'alpha') || contains(github.ref, 'rc') }}
draft: true
generateReleaseNotes: true
docs:
runs-on: ubuntu-latest
needs: whl
permissions:
contents: write
container:
image: python:alpine
env:
HOMEPAGE_URL: https://mdbackup.majorcadevs.com
steps:
- name: Install dependencies
run: apk add --no-cache git jq moreutils nodejs npm build-base
- uses: actions/checkout@v4
- name: Prepare git
run: |
# workaround for error in permissions
git config --global --add safe.directory "$GITHUB_WORKSPACE"
# fetch gh-pages
git fetch origin gh-pages --depth=1
- name: Install dependencies
run: |
pip install pipenv
pipenv install -d
- name: Build and publish docs (stable)
if: ${{ !contains(github.ref, 'beta') && !contains(github.ref, 'alpha') && !contains(github.ref, 'rc') }}
run: |
# get version
REF="${{ github.ref }}"
VERSION=${REF#refs/tags/v}
VERSION=${VERSION#refs/tags/}
VERSION=$(echo $VERSION | awk '{ split($0, a, "."); print a[1] "." a[2] }')
echo "Version family: $VERSION"
# build docs
pipenv run mike deploy --push --update-aliases $VERSION stable
- name: Build and publish docs (dev)
if: ${{ contains(github.ref, 'beta') || contains(github.ref, 'alpha') || contains(github.ref, 'rc') }}
run: |
# build docs
pipenv run mike deploy --push dev
- name: Deploy to GitHub Pages
uses: crazy-max/ghaction-github-pages@v3
with:
target_branch: gh-pages
build_dir: build/docs
fqdn: mdbackup.majorcadevs.com
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docker:
strategy:
matrix:
flavour:
- alpine
- slim
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
# Configure buildx and QEMU for cross-arch support
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Log in into the registry
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Parse tag
id: parser
run: |
REF="${{ github.ref }}"
if [[ $REF == refs/tags/* ]]; then
VERSION=${REF#refs/tags/v}
VERSION=${VERSION#refs/tags/}
else
echo "No idea how to decipher this ref: $REF"
exit 1
fi
echo ::set-output name=version::$VERSION
# Build and push Docker image with Buildx
- name: Build and push Docker image
if: ${{ contains(steps.parser.outputs.version, 'beta') || contains(steps.parser.outputs.version, 'alpha') || contains(steps.parser.outputs.version, 'rc') }}
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile-${{ matrix.flavour }}
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.parser.outputs.version }}-${{ matrix.flavour }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
- name: Build and push Docker image
if: ${{ !contains(steps.parser.outputs.version, 'beta') && !contains(steps.parser.outputs.version, 'alpha') && !contains(steps.parser.outputs.version, 'rc') }}
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile-${{ matrix.flavour }}
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.parser.outputs.version }}-${{ matrix.flavour }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.flavour }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64,linux/arm/v7