Skip to content

Commit beea668

Browse files
authored
Add workflow yml file for release (#41)
1 parent 24eb020 commit beea668

File tree

1 file changed

+132
-0
lines changed

1 file changed

+132
-0
lines changed

.github/workflows/release.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Copyright 2023, Oracle Corporation and/or its affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at
3+
# https://oss.oracle.com/licenses/upl.
4+
5+
# ---------------------------------------------------------------------------
6+
# Coherence Python Client GitHub Release Actions build.
7+
# ---------------------------------------------------------------------------
8+
9+
10+
name: Publish on Pypi and GitHub Pages
11+
12+
on:
13+
release:
14+
# This specifies that the build will be triggered when we publish a release
15+
types: [published]
16+
17+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
18+
permissions:
19+
contents: write
20+
pages: write
21+
id-token: write
22+
23+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
24+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
25+
concurrency:
26+
group: "pages"
27+
cancel-in-progress: false
28+
29+
jobs:
30+
build:
31+
runs-on: ubuntu-latest
32+
33+
steps:
34+
- uses: actions/checkout@v3
35+
- uses: actions/setup-python@v4
36+
with:
37+
python-version: "3.11.x"
38+
39+
- name: Install Poetry
40+
shell: bash
41+
run: |
42+
pip install poetry=="1.5.0"
43+
44+
- name: Install Dependencies
45+
run: python -m poetry install
46+
47+
- name: Generate docs
48+
shell: bash
49+
run: |
50+
python -m poetry run make docs
51+
52+
- name: Setup Pages
53+
id: pages
54+
uses: actions/configure-pages@v3
55+
56+
- name: Upload artifact
57+
uses: actions/upload-pages-artifact@v1
58+
with:
59+
name: "github-pages"
60+
path: ./docs/_build
61+
62+
- name: Download artifact
63+
uses: actions/download-artifact@v3
64+
with:
65+
name: github-pages
66+
path: .
67+
68+
- name: Publish to PyPi
69+
shell: bash
70+
env:
71+
TWINE_USERNAME: ${{ secrets.PYPI_USER }}
72+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
73+
run: |
74+
pip install --upgrade pip
75+
pip install build twine
76+
python3 -m build
77+
ls -la ./dist
78+
twine upload --repository testpypi dist/*
79+
- name: Get release version
80+
id: get-version
81+
run: |
82+
version=$(echo ${{github.event.release.tag_name}} | sed 's/v//')
83+
echo "get_release_ver=$version" >> "$GITHUB_ENV"
84+
- name: Print version
85+
run: |
86+
echo "${{ env.get_release_ver }}"
87+
- name: Attach whl artifact to release
88+
uses: actions/upload-release-asset@v1
89+
env:
90+
GITHUB_TOKEN: ${{ github.token }}
91+
with:
92+
upload_url: ${{ github.event.release.upload_url }}
93+
asset_path: ./dist/${{ format('coherence_client-{0}-py3-none-any.whl', env.get_release_ver) }}
94+
asset_name: ${{ format('coherence_client-{0}-py3-none-any.whl', env.get_release_ver ) }}
95+
asset_content_type: application/gzip
96+
- name: Attach tar.gz artifact to release
97+
uses: actions/upload-release-asset@v1
98+
env:
99+
GITHUB_TOKEN: ${{ github.token }}
100+
with:
101+
upload_url: ${{ github.event.release.upload_url }}
102+
asset_path: ./dist/${{ format('coherence_client-{0}.tar.gz', env.get_release_ver) }}
103+
asset_name: ${{ format('coherence_client-{0}.tar.gz', env.get_release_ver) }}
104+
asset_content_type: application/gzip
105+
- name: Attach doc zip to release
106+
uses: actions/upload-release-asset@v1
107+
env:
108+
GITHUB_TOKEN: ${{ github.token }}
109+
with:
110+
upload_url: ${{ github.event.release.upload_url }}
111+
asset_path: ./artifact.tar
112+
asset_name: ${{ format('coherence_client-{0}-doc.tar', env.get_release_ver) }}
113+
asset_content_type: application/gzip
114+
115+
# Deploy job
116+
deploy:
117+
# Add a dependency to the build job
118+
needs: build
119+
120+
# Deploy to the github-pages environment
121+
environment:
122+
name: github-pages
123+
url: ${{ steps.deployment.outputs.page_url }}
124+
125+
# Specify runner + deployment step
126+
runs-on: ubuntu-latest
127+
steps:
128+
- name: Deploy to GitHub Pages
129+
id: deployment
130+
uses: actions/deploy-pages@v2 # or the latest "vX.X.X" version tag for this action
131+
with:
132+
artifact_name: github-pages

0 commit comments

Comments
 (0)