This repository has been archived by the owner on Jan 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
142 lines (136 loc) · 4.52 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
name: Release
on:
pull_request:
branches:
- main
types:
- closed
paths: [src/**/*, main.py, requirements.txt, Dockerfile]
env:
PR_NUMBER: pr${{ github.event.number }}
jobs:
push:
name: Push Docker images
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
actions: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Dry run for Git tag
id: git_tag
uses: anothrNick/[email protected]
env:
DRY_RUN: true
DEFAULT_BUMP: patch
WITH_V: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare job outputs
id: op
run: |
echo "date=$(date +%Y-%m-%d)" >> "$GITHUB_OUTPUT"
echo "app_version=$(sed "s/^v//" <<< ${{ steps.git_tag.outputs.tag }})" >> "$GITHUB_OUTPUT"
- name: Download artifact
uses: dawidd6/action-download-artifact@v3
with:
name: ${{ github.event.repository.name }}-${{ env.PR_NUMBER }}
path: /tmp
workflow: build.yml
- name: Load image
run: |
docker load --input /tmp/${{ github.event.repository.name }}-${{ env.PR_NUMBER }}.tar
docker tag ${{ github.repository }}:${{ env.PR_NUMBER }} ${{ github.repository }}:${{ steps.git_tag.outputs.tag }}
docker tag ${{ github.repository }}:${{ env.PR_NUMBER }} ghcr.io/${{ github.repository }}:${{ steps.git_tag.outputs.tag }}
- name: Login to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Login to the GH Container registry
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Docker images to DockerHub
run: |
docker push docker.io/${{ github.repository }}:${{ steps.git_tag.outputs.tag }}
docker push docker.io/${{ github.repository }}:latest
- name: Push Docker images to GH Container registry
run: |
docker push ghcr.io/${{ github.repository }}:${{ steps.git_tag.outputs.tag }}
docker push ghcr.io/${{ github.repository }}:latest
outputs:
gitTag: ${{ steps.git_tag.outputs.tag }}
appVersion: ${{ steps.op.outputs.app_version }}
date: ${{ steps.op.outputs.date }}
bump:
name: Bump version
runs-on: ubuntu-latest
permissions:
packages: read
contents: write
needs: [push]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: Create Git tag
id: git_tag
uses: anothrNick/[email protected]
env:
DEFAULT_BUMP: patch
RELEASE_BRANCHES: main
WITH_V: true
PRERELEASE: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release:
name: Publish release
runs-on: ubuntu-latest
needs: [push, bump]
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Publish release
uses: ncipollo/[email protected]
with:
tag: ${{ needs.push.outputs.gitTag }}
name: ${{ needs.push.outputs.appVersion }} / ${{ needs.push.outputs.date }}
bodyFile: CHANGELOG.md
documentation:
name: Publish API documentation
runs-on: ubuntu-latest
needs: [push, bump]
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Start project with Docker Compose
run: |
cd docs/examples/docker && docker compose up -d
sleep 10
- name: Build Redocly page
uses: seeebiii/redoc-cli-github-action@v10
with:
args: bundle http://172.17.0.1:5000/openapi.json -o redoc/index.html
- name: Publish GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
allow_empty_commit: true
enable_jekyll: true
publish_dir: ./redoc
keep_files: true