-
Notifications
You must be signed in to change notification settings - Fork 0
162 lines (144 loc) · 5.73 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
name: Build and Release to Production
on:
push:
branches:
- main
permissions:
id-token: write
contents: write
packages: write
jobs:
determine-release:
runs-on: ubuntu-latest
environment: production
outputs:
release_needed: ${{ steps.semantic_release.outputs.release_needed }}
tag: ${{ steps.semantic_release.outputs.tag }}
env:
UV_TOOL_DIR: /tmp/.uv-tool
steps:
# https://github.com/orgs/community/discussions/25305#discussioncomment-10728028
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.sha }}
ssh-key: ${{ secrets.GH_DEPLOY_SSH_KEY }}
- name: Force correct release branch
run: |
git checkout -B ${{ github.ref_name }} ${{ github.sha }}
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
tool-bin-dir: "/tmp/tool-bin"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: "backend/pyproject.toml"
- name: Restore uv tools
uses: actions/cache@v4
with:
path: /tmp/tool-bin
key: uv-tools-${{ runner.os }}-psr-v9.11.1
restore-keys: |
uv-tools-${{ runner.os }}-psr-v9.11.1
uv-tools-${{ runner.os }}
- name: Install Python Semantic Release
env:
UV_TOOL_DIR: /tmp/release-tool-bin
run: uv tool install python-semantic-release@v9.11.1
- name: Run Semantic Release
id: semantic_release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./scripts/release-needed.sh
build-frontend-docker:
needs: determine-release
if: needs.determine-release.outputs.release_needed == 'true'
uses: ./.github/workflows/frontend-docker.yml
with:
tag: ${{ needs.determine-release.outputs.tag }}
secrets: inherit
build-backend-docker:
needs: determine-release
if: needs.determine-release.outputs.release_needed == 'true'
uses: ./.github/workflows/backend-docker.yml
with:
tag: ${{ needs.determine-release.outputs.tag }}
secrets: inherit
build-frontend:
needs: [build-frontend-docker, determine-release]
if: needs.determine-release.outputs.release_needed == 'true'
uses: ./.github/workflows/frontend.yml
with:
tag: ${{ needs.determine-release.outputs.tag }}
secrets: inherit
release-github:
needs: [build-backend-docker, build-frontend, determine-release]
if: needs.determine-release.outputs.release_needed == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ needs.determine-release.outputs.tag }}
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
name: frontend-build
path: dist/frontend/
- name: Create Frontend Build Archive
run: cd dist/ && tar -czf frontend-build.tar frontend/
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: dist/frontend-build.tar
tag_name: ${{ needs.determine-release.outputs.tag }}
body_path: CHANGELOG.md
release-docker:
needs: [release-github, determine-release]
if: needs.determine-release.outputs.release_needed == 'true'
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
- name: Create Frontend Docker Release
uses: ./.github/actions/docker-release
with:
release_tag: ${{ needs.determine-release.outputs.tag }}
image_name: ${{ vars.FRONTEND_IMAGE_NAME }}
old_tag: main-dev
registry: ${{ vars.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create Backend Docker Release
uses: ./.github/actions/docker-release
with:
release_tag: ${{ needs.determine-release.outputs.tag }}
image_name: ${{ vars.BACKEND_IMAGE_NAME }}
old_tag: main
registry: ${{ vars.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
release-cloudflare:
needs: [build-frontend, release-github, determine-release]
if: needs.determine-release.outputs.release_needed == 'true'
runs-on: ubuntu-latest
environment:
name: production
url: ${{ steps.deploy.outputs.deployment-url }}
steps:
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
name: frontend-build
path: dist/frontend/
- name: Upload Build Artifacts
uses: cloudflare/wrangler-action@v3
id: deploy
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy dist/frontend/ --project-name=tmvisdb