-
Notifications
You must be signed in to change notification settings - Fork 2
147 lines (128 loc) · 4.47 KB
/
build-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
name: Build and release project
on:
push:
branches: [ main ]
paths-ignore:
- '**.md'
- '!.changeset/**'
- 'LICENSE'
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
REPO_NAME: snipcode
concurrency:
group: "${{ github.workflow }}-${{ github.head_ref || github.run_id }}"
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
env:
NODE_ENV: test
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test
MYSQL_PORT: 3306
DATABASE_URL: mysql://root:[email protected]:3306/test
ADMIN_PASSWORD: admin_password
CONVERTKIT_API_KEY: api_key
CONVERTKIT_FORM_ID: form_id
steps:
- uses: actions/checkout@v4
- name: Install dependencies
uses: ./.github/actions/install-dependencies
- name: Lint the projects
run: yarn lint
- name: Build the projects
run: yarn build
- name: Start MySQL server
run: sudo systemctl start mysql.service
- name: Run tests
run: |
yarn prisma migrate dev --schema=packages/domain/prisma/schema.prisma
yarn test
version:
runs-on: ubuntu-latest
needs:
- build
outputs:
hasChangesets: ${{ steps.changesets.outputs.hasChangesets }}
releaseArtifactId: ${{ steps.artifact-release-upload.outputs.artifact-id }}
steps:
- uses: actions/checkout@v4
- name: Install dependencies
uses: ./.github/actions/install-dependencies
- name: Print Released Packages
id: releasedPackages
run: yarn changeset status --output=release.json
- name: Upload Release File
uses: actions/upload-artifact@v4
id: artifact-release-upload
with:
name: released-packages
path: release.json
- name: Create Release Pull Request
id: changesets
uses: changesets/action@v1
with:
commit: 'chore: update versions'
title: 'chore: update versions'
createGithubReleases: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GH_PAT }}
GH_BRANCH: ${{ github.head_ref || github.ref_name }}
needs:
- version
if: needs.version.outputs.hasChangesets == 'true'
steps:
- uses: actions/checkout@v4
- name: Download Release File
uses: actions/download-artifact@v4
with:
name: released-packages
- name: Trigger Backend Release
run: |
BACKEND_VERSION=$(jq -r '.releases[] | select(.name == "@snipcode/core") | .newVersion' release.json)
if [ -n "$BACKEND_VERSION" ]; then
echo "Ready to release Backend version $BACKEND_VERSION"
gh workflow run deploy-backend.yml -r "${{ secrets.GH_BRANCH }}" -f version=$BACKEND_VERSION
else
echo "No Backend Release"
fi
- name: Trigger Frontend Release
continue-on-error: true
run: |
FRONTEND_VERSION=$(jq -r '.releases[] | select(.name == "@snipcode/web") | .newVersion' release.json)
if [ -n "$FRONTEND_VERSION" ]; then
echo "Ready to release Frontend version $FRONTEND_VERSION"
gh workflow run deploy-frontend.yml -r "${{ secrets.GH_BRANCH }}" -f version=$FRONTEND_VERSION
else
echo "No Frontend Release"
fi
- name: Trigger Embed Release
continue-on-error: true
run: |
EMBED_VERSION=$(jq -r '.releases[] | select(.name == "@snipcode/embed") | .newVersion' release.json)
if [ -n "$EMBED_VERSION" ]; then
echo "Ready to release Embed version $EMBED_VERSION"
gh workflow run deploy-embed.yml -r "${{ secrets.GH_BRANCH }}" -f version=$EMBED_VERSION
else
echo "No Embed Release"
fi
- name: Delete Release File
if: ${{ success() }}
env:
ARTIFACT_ID: ${{ needs.version.outputs.releaseArtifactId }}
run: |
set -e
echo "Deleting artefact $ARTIFACT_ID"
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GH_PAT }}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/tericcabrel/$REPO_NAME/actions/artifacts/$ARTIFACT_ID