-
Notifications
You must be signed in to change notification settings - Fork 9
106 lines (89 loc) · 3.52 KB
/
shared-build-and-deploy.yml
File metadata and controls
106 lines (89 loc) · 3.52 KB
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
name: Shared Build and Deploy
on:
workflow_call:
inputs:
ref:
description: 'Git reference to use (e.g., main or branch name)'
required: true
type: string
tag:
description: 'Release Tag'
required: true
type: string
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Resolve Branch for the Tagged Commit
id: resolve-branch
if: ${{ inputs.tag == 'beta' || inputs.tag == 'public' }}
run: |
TAG_COMMIT=$(git rev-list -n 1 ${{ github.ref_name }})
BRANCH_NAME=$(git branch -r --contains $TAG_COMMIT | grep -o 'origin/.*' | sed 's|origin/||' | head -n 1)
if [ -z "$BRANCH_NAME" ]; then
echo "Error: Could not resolve branch for the tag."
exit 1
fi
echo "Resolved Branch Name: $BRANCH_NAME"
echo "branch_name=$BRANCH_NAME" >> $GITHUB_ENV
- name: Get Previous tag
id: previoustag
uses: WyriHaximus/github-action-get-previous-tag@v1
with:
fallback: 1.0.0
- name: Bump Version
run: |
chmod +x ./ci-scripts/bump_version.sh
if ${{ inputs.tag == 'internal' }}; then
./ci-scripts/bump_version.sh "${{ steps.previoustag.outputs.tag }}" "$(git rev-parse --short "$GITHUB_SHA")"
else
./ci-scripts/bump_version.sh "${{ steps.previoustag.outputs.tag }}"
fi
- name: Commit changes
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
if [[ "${{ inputs.tag }}" == "beta" || "${{ inputs.tag }}" == "public" ]]; then
git checkout ${{ env.branch_name }}
fi
git add setup.py
git add skyflow/utils/_version.py
if [[ "${{ inputs.tag }}" == "internal" ]]; then
VERSION="${{ steps.previoustag.outputs.tag }}.dev0+$(git rev-parse --short $GITHUB_SHA)"
COMMIT_MESSAGE="[AUTOMATED] Private Release $VERSION"
git commit -m "$COMMIT_MESSAGE"
git push origin ${{ github.ref_name }} -f
fi
if [[ "${{ inputs.tag }}" == "beta" || "${{ inputs.tag }}" == "public" ]]; then
COMMIT_MESSAGE="[AUTOMATED] Public Release - ${{ steps.previoustag.outputs.tag }}"
git commit -m "$COMMIT_MESSAGE"
git push origin ${{ env.branch_name }}
fi
- name: Build and install skyflow package
run: |
python setup.py sdist bdist_wheel
pip install dist/skyflow-*.whl
- name: Build and Publish Package
if: ${{ inputs.tag == 'beta' || inputs.tag == 'public' }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PUBLISH_TOKEN }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
- name: Build and Publish to JFrog Artifactory
if: ${{ inputs.tag == 'internal' }}
env:
TWINE_USERNAME: ${{ secrets.JFROG_USERNAME }}
TWINE_PASSWORD: ${{ secrets.JFROG_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload --repository-url https://prekarilabs.jfrog.io/artifactory/api/pypi/skyflow-python/ dist/*