-
Notifications
You must be signed in to change notification settings - Fork 15
128 lines (111 loc) · 5.05 KB
/
Publish_NIMS.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
name: Publish NIMS
on:
release:
types: [published]
workflow_dispatch:
concurrency: publish_to_pypi
env:
# Versions are also listed in PR.yml
POETRY_VERSION: 1.8.2
PYTHON_VERSION: 3.9
jobs:
check_nims:
name: Check NIMS
uses: ./.github/workflows/check_nims.yml
check_nimg:
name: Check NIMG
uses: ./.github/workflows/check_nimg.yml
# Don't run check_examples.yml because the examples may reference a
# package version that doesn't exist yet.
build:
name: Build
runs-on : ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Set up Poetry
uses: Gr1N/setup-poetry@v9
with:
poetry-version: ${{ env.POETRY_VERSION }}
- name: Check for lock changes
run: poetry check --lock
working-directory: ./packages/service
# If the tag is 0.1.0, this will set the version of NIMS package to 0.1.0
- name: Store version from Tag
id: vars
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Update NIMS package version based on tag name.
run: |
poetry version ${{ steps.vars.outputs.tag }}
working-directory: ./packages/service
- name: Update NIMG package version based on tag name.
run: |
poetry version ${{ steps.vars.outputs.tag }}
working-directory: ./packages/generator
- name: Update SDK package version based on tag name.
run: |
poetry version ${{ steps.vars.outputs.tag }}
working-directory: ./packages/sdk
- name: Commit file changes
id: commit
if: ${{ startsWith(github.event.release.target_commitish, 'main') || startsWith(github.event.release.target_commitish, 'releases/') }}
run: |
echo "version_changed=false" >> $GITHUB_OUTPUT
if [ -n "$(git status --porcelain)" ]; then
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add .
git commit -m "Promote NIMS and NIMG package version" -a
echo "version_changed=true" >> $GITHUB_OUTPUT
fi
- name: Push changes to the appropriate branch
if: ${{ steps.commit.outputs.version_changed && (startsWith(github.event.release.target_commitish, 'main') || startsWith(github.event.release.target_commitish, 'releases/')) }}
uses: CasperWA/push-protected@v2
with:
token: ${{ secrets.ADMIN_PAT }}
branch: ${{ github.event.release.target_commitish }}
unprotect_reviews: true
# To Test the Publish use : poetry publish --build --username __token__ --password ${{ secrets.TEST_PYPI_TOKEN }} -r test-pypi
- name: Build NIMS Python package and publish to PyPI
if: ${{ startsWith(github.event.release.target_commitish, 'main') || startsWith(github.event.release.target_commitish, 'releases/') }}
run: |
poetry publish --build --username __token__ --password ${{ secrets.PYPI_TOKEN }}
working-directory: ./packages/service
- name: Build NIMG Python package and publish to PyPI
if: ${{ startsWith(github.event.release.target_commitish, 'main') || startsWith(github.event.release.target_commitish, 'releases/') }}
run: |
poetry publish --build --username __token__ --password ${{ secrets.PYPI_TOKEN }}
working-directory: ./packages/generator
- name: Build SDK Python package and publish to PyPI
if: ${{ startsWith(github.event.release.target_commitish, 'main') || startsWith(github.event.release.target_commitish, 'releases/') }}
run: |
poetry publish --build --username __token__ --password ${{ secrets.PYPI_TOKEN }}
working-directory: ./packages/sdk
- name: Create archives of the examples
env:
EXAMPLE_ARCHIVE: measurement-plugin-python-examples-${{ steps.vars.outputs.tag }}
run: |
# Use --prefix for the tarball but not the zip file. Windows zip tools often create a directory automatically.
rm -rf dist
mkdir -p dist
git archive -o dist/${EXAMPLE_ARCHIVE}.zip ${GITHUB_REF}:examples/
git archive -o dist/${EXAMPLE_ARCHIVE}.tar.gz --prefix ${EXAMPLE_ARCHIVE}/ ${GITHUB_REF}:examples/
- name: Upload release assets
if: ${{ startsWith(github.event.release.target_commitish, 'main') || startsWith(github.event.release.target_commitish, 'releases/') }}
uses: ncipollo/release-action@v1
with:
artifacts: "dist/measurement-plugin-python-examples-*"
allowUpdates: true
omitBodyDuringUpdate: true
omitDraftDuringUpdate: true
omitNameDuringUpdate: true
omitPrereleaseDuringUpdate: true
updateOnlyUnreleased: false
- uses: actions/upload-artifact@v4
with:
name: NIMS Artifacts
path: ./packages/service/dist/ # path/to/artifact