forked from nautobot/nautobot
-
Notifications
You must be signed in to change notification settings - Fork 0
179 lines (175 loc) · 6.92 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
---
name: "Release"
on:
release:
types: ["released"]
jobs:
# Ensure CI has passed
ci:
uses: nautobot/nautobot/.github/workflows/ci_integration.yml@main
# Publish to GitHub followed by pypi
publish_python:
needs:
- "ci"
name: "Publish Python Packages"
runs-on: "ubuntu-20.04"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v2"
- name: "Set up Python"
uses: "actions/setup-python@v2"
with:
python-version: "3.11"
- name: "Install Python Packages"
run: "pip install poetry"
- name: "Configure Poetry"
run: "poetry config virtualenvs.create false && poetry config installer.parallel false"
- name: "Install Dependencies (needed for mkdocs)"
run: "poetry install --no-root"
- name: "Build Documentation"
run: "poetry run mkdocs build --no-directory-urls --strict"
- name: "Run Poetry Build"
run: "poetry build"
- name: "Upload binaries to release"
uses: "svenstaro/upload-release-action@v2"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
file: "dist/*"
tag: "${{ github.ref }}"
overwrite: true
file_glob: true
- name: "Push to PyPI"
uses: "pypa/gh-action-pypi-publish@release/v1"
with:
user: "__token__"
password: "${{ secrets.PYPI_API_TOKEN }}"
publish_containers:
name: "Build & Publish Container Images"
runs-on: "ubuntu-22.04"
needs:
- "ci"
strategy:
fail-fast: true
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
env:
INVOKE_NAUTOBOT_PYTHON_VER: "${{ matrix.python-version }}"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v3"
- run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
id: "gitbranch"
- name: "Set up QEMU"
uses: "docker/setup-qemu-action@v2"
- name: "Set up Docker Buildx"
uses: "docker/setup-buildx-action@v2"
- name: "Login to GitHub Container Registry"
uses: "docker/login-action@v2"
with:
registry: "ghcr.io"
username: "${{ github.actor }}"
password: "${{ secrets.GITHUB_TOKEN }}"
- name: "Login to Docker"
uses: "docker/login-action@v2"
with:
username: "${{ secrets.DOCKERHUB_USERNAME }}"
password: "${{ secrets.DOCKERHUB_TOKEN }}"
- name: "Docker Metadata"
id: "dockermeta"
uses: "docker/metadata-action@v4"
with:
images: "networktocode/nautobot,ghcr.io/nautobot/nautobot"
flavor: |
latest=${{ matrix.python-version == 3.11 }}
tags: |
type=semver,pattern={{version}}-py${{ matrix.python-version }}
type=semver,pattern={{version}},enable=${{ matrix.python-version == 3.11 }}
type=semver,pattern={{major}}.{{minor}}-py${{ matrix.python-version }}
type=semver,pattern={{major}}.{{minor}},enable=${{ matrix.python-version == 3.11 }}
type=raw,value=latest-py${{ matrix.python-version }}
type=raw,value=stable,enable=${{ matrix.python-version == 3.11 }}
type=raw,value=stable-py${{ matrix.python-version }}
labels: |
org.opencontainers.image.title=Nautobot
- name: "Build"
uses: "docker/build-push-action@v4"
with:
push: true
target: final
file: "docker/Dockerfile"
platforms: "linux/amd64,linux/arm64"
tags: "${{ steps.dockermeta.outputs.tags }}"
labels: "${{ steps.dockermeta.outputs.labels }}"
cache-from: "type=gha,scope=nautobot-${{ steps.gitbranch.outputs.branch }}-${{ matrix.python-version }}"
cache-to: "type=gha,mode=max,scope=nautobot-${{ steps.gitbranch.outputs.branch }}-${{ matrix.python-version }}"
context: "."
build-args: |
PYTHON_VER=${{ matrix.python-version }}
POETRY_INSTALLER_PARALLEL=true
- name: "Docker Dev Metadata"
id: "dockerdevmeta"
uses: "docker/metadata-action@v4"
with:
images: "networktocode/nautobot-dev,ghcr.io/nautobot/nautobot-dev"
flavor: |
latest=${{ matrix.python-version == 3.11 }}
tags: |
type=semver,pattern={{version}}-py${{ matrix.python-version }}
type=semver,pattern={{version}},enable=${{ matrix.python-version == 3.11 }}
type=semver,pattern={{major}}.{{minor}}-py${{ matrix.python-version }}
type=semver,pattern={{major}}.{{minor}},enable=${{ matrix.python-version == 3.11 }}
type=raw,value=latest-py${{ matrix.python-version }}
type=raw,value=stable,enable=${{ matrix.python-version == 3.11 }}
type=raw,value=stable-py${{ matrix.python-version }}
labels: |
org.opencontainers.image.title=Nautobot
- name: "Build Dev Containers"
uses: "docker/build-push-action@v4"
with:
push: true
target: final-dev
file: "docker/Dockerfile"
platforms: "linux/amd64,linux/arm64"
tags: "${{ steps.dockerdevmeta.outputs.tags }}"
labels: "${{ steps.dockerdevmeta.outputs.labels }}"
cache-from: "type=gha,scope=nautobot-${{ steps.gitbranch.outputs.branch }}-${{ matrix.python-version }}"
cache-to: "type=gha,mode=max,scope=nautobot-${{ steps.gitbranch.outputs.branch }}-${{ matrix.python-version }}"
context: "."
build-args: |
PYTHON_VER=${{ matrix.python-version }}
POETRY_INSTALLER_PARALLEL=true
slack-notify:
needs:
- "publish_python"
- "publish_containers"
runs-on: "ubuntu-20.04"
env:
SLACK_WEBHOOK_URL: "${{ secrets.SLACK_WEBHOOK_URL }}"
SLACK_MESSAGE: >-
*NOTIFICATION: NEW-RELEASE-PUBLISHED*\n
Repository: <${{ github.server_url }}/${{ github.repository }}|${{ github.repository }}>\n
Release: <${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }}|${{ github.ref_name }}>\n
Published by: <${{ github.server_url }}/${{ github.actor }}|${{ github.actor }}>
steps:
- name: "Send a notification to Slack"
# ENVs cannot be used directly in job.if. This is a workaround to check
# if SLACK_WEBHOOK_URL is present.
if: "${{ env.SLACK_WEBHOOK_URL != '' }}"
uses: "slackapi/[email protected]"
with:
payload: |
{
"text": "${{ env.SLACK_MESSAGE }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${{ env.SLACK_MESSAGE }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: "${{ secrets.SLACK_WEBHOOK_URL }}"
SLACK_WEBHOOK_TYPE: "INCOMING_WEBHOOK"