-
-
Notifications
You must be signed in to change notification settings - Fork 99
160 lines (136 loc) · 4.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
152
153
154
155
156
157
158
159
160
name: Publish containers and make release
on:
push:
branches: ['master', 'test_release_branch']
tags:
- '*'
workflow_dispatch:
env:
REGISTRY: ghcr.io
PYTHON_VERSION: 3.9
jobs:
build_containers:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Cargo download work-around
run: |
mkdir -p ~/.cargo
cat <<EOF > ~/.cargo/config.toml
[net]
git-fetch-with-cli = true
EOF
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Build wheel
id: wheel
run: |
# If not a release branch, add SHA1 to patch version
if [ "$(python scripts/version.py is_release)" = "false" ]; then
python scripts/version.py sha1
fi
python -m pip install --upgrade setuptools pip wheel
python setup.py sdist bdist_wheel
echo "version=$(python scripts/version.py get)" >> $GITHUB_OUTPUT
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
labels: |
org.opencontainers.image.ref.name=${{ github.ref }}
tags: |
type=ref,event=branch
type=ref,event=pr,
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
github-token: ${{ secrets.GITHUB_TOKEN }}
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64,linux/arm64
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.wheel.outputs.version }}
- name: Upload built artifacts
uses: actions/upload-artifact@v3
with:
name: packages
path: |
dist
make_release:
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
needs: build_containers
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Download pre-built packages
uses: actions/[email protected]
with:
name: packages
path: dist
- name: Extract release notes and name
id: info
shell: python {0}
run: |
import os
import re
name = None
version = None
notes = ""
with open("CHANGES.md", "r", encoding="utf-8") as handle:
for line in handle:
if line.startswith("##"):
if name is None:
version, name = re.match(r"## ([0-9.]+) ([^(]+) \(.*", line).groups()
else:
break
if name is not None:
notes += line
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as fh:
fh.writelines([f"name={name}\n", f"version={version}\n"])
with open("notes.md", "w", encoding="utf-8") as handle:
handle.write(notes)
- name: Publish release
uses: ncipollo/release-action@v1
with:
artifacts: "dist/pyatv-${{ steps.info.outputs.version }}.tar.gz,dist/pyatv-${{ steps.info.outputs.version }}-*.whl"
bodyFile: "notes.md"
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
tag: v${{ steps.info.outputs.version }}
name: ${{ steps.info.outputs.name }}
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
skip_existing: true