-
Notifications
You must be signed in to change notification settings - Fork 3
128 lines (114 loc) · 3.6 KB
/
release-version.yaml
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
name: Release Python SDK
on:
workflow_dispatch:
inputs:
env:
default: 'test'
description: 'PyPi env'
required: true
type: choice
options:
- dev
- test
- prod
jobs:
release-version:
runs-on: ubuntu-latest
name: Release sdk
steps:
- id: checkout
name: Checkout repo
uses: actions/checkout@v3
with:
token: ${{ secrets.FATTUREINCLOUD_BOT_TOKEN }}
- id: init-git
name: Init GIT
run: |
git config --global user.email "[email protected]"
git config --global user.name "fattureincloud-bot"
- id: setup-node
name: Setup Node.js
uses: actions/setup-node@v3
- id: setup-python
name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.9'
- id: install-dependencies
name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- id: setup-libraries
name: Install libraries
run: |
npm install -g yarn
yarn global add standard-version
sudo add-apt-repository ppa:rmescandon/yq -y
sudo apt update
sudo apt install yq -y
cd ./scripts/
yarn
# We read the version from the sdk-version.yaml file and create the tag
# If it is needed to bump version, launch the related workflow
- id: read-python-sdk-version
name: Read Python SDK version
run: |
SDK_VERSION=$(yq e '.info.version' ./sdk-version.yaml)
echo "Releasing version: $SDK_VERSION"
echo "sdk_version=$SDK_VERSION" >> $GITHUB_ENV
# Here we use standard-version just to generate the changelog
- id: generate-changelog
name: Generate Changelog
run: |
standard-version --skip.bump --skip.tag
- id: git-push
name: Pushing to Git repo
if: ${{ !env.ACT && github.event.inputs.env == 'prod' }}
run: |
git push origin
- id: save-commit-sha
name: Save latest commit sha
run: |
COMMIT_SHA=$(git rev-parse HEAD)
echo "commit_sha=$COMMIT_SHA" >> $GITHUB_ENV
- id: create-tag
name: Create tag
if: ${{ !env.ACT && github.event.inputs.env == 'prod' }}
uses: actions/github-script@v6
with:
github-token: ${{ github.token }}
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/v${{ env.sdk_version }}",
sha: "${{ env.commit_sha }}"
})
- id: build-package
name: Build package
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- id: skip-pypi-publish
name: Skipping publishing
if: ${{ env.ACT || github.event.inputs.env == 'dev' }}
run: |
echo "Skipping publishing"
- id: test-pypi-publish
name: Publish to Test PyPI
if: ${{ !env.ACT && github.event.inputs.env == 'test' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- id: pypi-publish
name: Publish to PyPI
if: ${{ !env.ACT && github.event.inputs.env == 'prod' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}