-
Notifications
You must be signed in to change notification settings - Fork 1
153 lines (134 loc) · 4.91 KB
/
build_and_publish.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
name: Check PR cloud2sql
on:
push:
tags:
- '*.*.*'
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
jobs:
cloud2sql:
name: 'cloud2sql'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
architecture: 'x64'
- name: Restore dependency cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{runner.os}}-pip-${{hashFiles('**/requirements*.txt')}}
restore-keys: |
${{runner.os}}-pip-
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install tox wheel flake8 build
- name: Run tests
run: tox
- name: Build a binary wheel and a source tarball
run: >-
python -m build --sdist --wheel --outdir dist/
- name: Publish distribution to PyPI
if: github.ref_type == 'tag'
continue-on-error: true # Ignore failure to publish to PyPI (e.g., when re-tagging a release)
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_CLOUD2SQL }}
packages_dir: ./dist/
- name: Build binary
id: pyinstaller
run: |
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt \
-r requirements-mysql.txt \
-r requirements-postgresql.txt \
-r requirements-parquet.txt \
-r requirements-snowflake.txt
pip install pyinstaller
pyinstaller --clean --noconfirm --log-level=WARN --distpath=dist --workpath=build cloud2sql.spec
if [ "${{ github.ref_type }}" = tag ]; then
echo "target=cloud2sql-${{ github.ref_name }}.linux-amd64" >> $GITHUB_OUTPUT
else
echo "target=cloud2sql-${GITHUB_SHA::7}.linux-amd64" >> $GITHUB_OUTPUT
fi
- name: Move binary
run: |
mv dist/cloud2sql dist/${{ steps.pyinstaller.outputs.target }}
- name: Upload artifact
if: github.event_name != 'pull_request' && github.event_name != 'workflow_dispatch'
uses: actions/upload-artifact@v3
with:
name: ${{ steps.pyinstaller.outputs.target }}
path: dist/${{ steps.pyinstaller.outputs.target }}
docs:
name: Update cloud2sql.com
if: github.ref_type == 'tag'
needs:
- cloud2sql
runs-on: ubuntu-latest
steps:
- name: Get release tag and type
id: release
shell: bash
run: |
GITHUB_REF="${{ github.ref }}"
tag=${GITHUB_REF##*/}
echo "tag=${tag}" >> $GITHUB_OUTPUT
if [[ ${{ github.ref }} =~ ^refs/tags/[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "prerelease=false" >> $GITHUB_OUTPUT
else
echo "prerelease=true" >> $GITHUB_OUTPUT
fi
- name: Check out someengineering/cloud2sql.com
if: steps.release.outputs.prerelease == 'false'
uses: actions/checkout@v3
with:
repository: someengineering/cloud2sql.com
path: cloud2sql.com
token: ${{ secrets.SOME_CI_PAT }}
- name: Install dependencies
if: steps.release.outputs.prerelease == 'false'
working-directory: ./cloud2sql.com
run: |
yarn install --frozen-lockfile
- name: Update released version
if: steps.release.outputs.prerelease == 'false'
shell: bash
working-directory: ./cloud2sql.com
run: |
echo $(jq '.version="${{ steps.release.outputs.tag }}" | .link="https://github.com/someengineering/cloud2sql/releases/tag/${{ steps.release.outputs.tag }}"' latestRelease.json) > latestRelease.json
yarn format
- name: Create someengineering/cloud2sql.com pull request
if: steps.release.outputs.prerelease == 'false'
uses: peter-evans/create-pull-request@v4
env:
HUSKY: 0
with:
path: cloud2sql.com
commit-message: 'chore: update Cloud2SQL version to ${{ steps.release.outputs.tag }}'
title: 'chore: update Cloud2SQL version to ${{ steps.release.outputs.tag }}'
body: |
Updates Cloud2SQL version on cloud2sql.com to `${{ steps.release.outputs.tag }}`.
labels: |
🤖 bot
branch: ${{ steps.release.outputs.tag }}
delete-branch: true
token: ${{ secrets.SOME_CI_PAT }}
committer: C.K. <[email protected]>
author: C.K. <[email protected]>
- name: Create release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: ${{steps.release.outputs.prerelease}}