-
Notifications
You must be signed in to change notification settings - Fork 10
127 lines (125 loc) · 4.58 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
name: Release workflow
on:
release:
types:
- "published"
jobs:
update-version:
runs-on: ubuntu-22.04
name: Update package version numbers
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: main
- name: Setup Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
# See: https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions
- name: Get version number from git tag
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v?}" >> $GITHUB_ENV # See: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
- name: Install toml-cli to modify toml file
# See: https://pypi.org/project/toml-cli/
run: |
python -m pip install toml-cli
- name: Update version in Ballerina.toml files
run: |
OLD_VERSION=$(toml get --toml-path api/Ballerina.toml package.version)
echo "Old package version: ${OLD_VERSION}"
echo "New package veresion: ${{ env.RELEASE_VERSION }}"
toml set --toml-path api/Ballerina.toml package.version ${{ env.RELEASE_VERSION }}
toml set --toml-path client/Ballerina.toml package.version ${{ env.RELEASE_VERSION }}
echo "Successfully updated package.version in api/Ballerina.toml and client/Ballerina.toml from ${OLD_VERSION} to version ${{ env.RELEASE_VERSION }}"
- name: Commit version changes to repository
uses: EndBug/add-and-commit@v9 # See: https://github.com/marketplace/actions/add-commit
with:
add: "."
push: origin main
default_author: github_actions
message: "Update version in Ballerina.toml files"
update-staging-db:
name: Update Azure staging database
needs: update-version
runs-on: ubuntu-22.04
environment: Staging
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Update Azure staging database
run: |
cat ./db/schema/*.sql | mysql --host=$HOST --port=$PORT --user=$USER --password=$PASSWORD
env:
HOST: ${{ secrets.DB_HOST }}
PORT: ${{ secrets.DB_PORT }}
USER: ${{ secrets.DB_USER }}
PASSWORD: ${{ secrets.DB_PASSWORD }}
DATABASE: ${{ secrets.DB_DATABASE }}
update-new-staging-db:
name: Update new Azure staging database
needs: update-version
runs-on: ubuntu-22.04
environment: Stage
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Update Azure staging database
run: |
cat ./db/schema/*.sql | mysql --host=$HOST --port=$PORT --user=$USER --password=$PASSWORD
env:
HOST: ${{ secrets.DB_HOST }}
PORT: ${{ secrets.DB_PORT }}
USER: ${{ secrets.DB_USER }}
PASSWORD: ${{ secrets.DB_PASSWORD }}
DATABASE: ${{ secrets.DB_DATABASE }}
update-production-database:
name: Update Production Azure Database
needs: update-version
runs-on: ubuntu-22.04
environment: Production
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Update Azure production database
run: |
cat ./db/schema/*.sql | mysql --host=$HOST --port=$PORT --user=$USER --password=$PASSWORD
env:
HOST: ${{ secrets.DB_HOST }}
PORT: ${{ secrets.DB_PORT }}
USER: ${{ secrets.DB_USER }}
PASSWORD: ${{ secrets.DB_PASSWORD }}
DATABASE: ${{ secrets.DB_DATABASE }}
push-api-client:
name: Publish GraphQL API Client
needs: update-staging-db
runs-on: ubuntu-22.04
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: main
- name: Build distribution archive of client package
uses: ballerina-platform/ballerina-action@394eb82cc07e020948fee8d1474143ae393147f4
with:
args: pack
env:
WORKING_DIR: client
- name: Push to central
uses: ballerina-platform/ballerina-action@394eb82cc07e020948fee8d1474143ae393147f4
with:
args: push
env:
WORKING_DIR: client
BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_ACCESS_TOKEN }}
update-documentation:
name: Update documentation
needs: push-api-client
uses: avinyafoundation/global-data/.github/workflows/pages.yml@main