-
Notifications
You must be signed in to change notification settings - Fork 2
133 lines (111 loc) · 3.46 KB
/
Copy pathci.yaml
File metadata and controls
133 lines (111 loc) · 3.46 KB
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: chkdns
on:
push:
tags:
- v*
pull_request:
branches:
- main
workflow_dispatch:
env:
IMAGE_NAME: chkdns
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python 🐍
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install and configure Poetry 🎉
uses: snok/install-poetry@v1
with:
version: 1.1.10
virtualenvs-in-project: true
- name: Install dependencies 🚧
run: poetry install
- name: Run linters 👷
run: |
source $VENV
make check
publish:
runs-on: ubuntu-latest
if: ${{ (github.event_name == 'push') || (github.event_name == 'pull_request' && github.actor == github.repository_owner) }}
needs:
- "lint"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python 🐍
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.1.10
virtualenvs-in-project: true
- name: Install dependencies 🚧
run: poetry install
- name: Build 👷
run: |
source $VENV
make build
- name: Publish 📦
if: startsWith(github.ref, 'refs/tags/v')
run: |
poetry config pypi-token.pypi $POETRY_PYPI_TOKEN_PYPI
poetry publish
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
- name: Build image 🐳
run: docker build . --file Dockerfile --tag chkdns
- name: Log into registry 🐳
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image 🐳
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
if [[ "${{ github.ref }}" == "refs/tags/v"* ]]; then
docker tag $IMAGE_NAME $IMAGE_ID:$(echo $VERSION | sed -e 's/^v//')
# latest should always reflect the most recent tagged release
VERSION=latest
elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
# main represents the latest build from main branch
VERSION=main
else
# dev represents the latest build from prs or branches
VERSION=dev
fi
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push -a $IMAGE_ID
- name: Push version change ✅
if: startsWith(github.ref, 'refs/tags/v')
uses: peter-evans/create-pull-request@v3
with:
title: Bump pyproject.toml
commit-message: "bump pyproject.toml"
branch: bump_version
body: This PR bumps pyproject.toml from ${{ github.ref }}
base: main
- name: Build Changelog 📝
if: startsWith(github.ref, 'refs/tags/v')
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v1
with:
configuration: "changelog.json"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release 🚀
if: startsWith(github.ref, 'refs/tags/v')
id: create_release
uses: ncipollo/release-action@v1
with:
name: chkdns
body: ${{steps.build_changelog.outputs.changelog}}
token: ${{ secrets.GITHUB_TOKEN }}