Skip to content

Commit 34e9e38

Browse files
authored
publish to anaconda
* initial version * read version from setup.py * build from local source * added conda build and publish steps * fix spacing * added conda install command
1 parent 3e05219 commit 34e9e38

File tree

3 files changed

+133
-10
lines changed

3 files changed

+133
-10
lines changed

.conda/meta.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{% set data = load_setup_py_data(setup_file='../setup.py', from_recipe_dir=True) %}
2+
{% set name = "sasctl" %}
3+
{% set version = data.get('version') %}
4+
5+
package:
6+
name: {{ name|lower }}
7+
version: {{ data.version }}
8+
9+
source:
10+
path: ..
11+
12+
build:
13+
entry_points:
14+
- sasctl = sasctl.utils.cli:main
15+
noarch: python
16+
script: {{ PYTHON }} -m pip install . -vv
17+
number: 0
18+
19+
requirements:
20+
host:
21+
- python >=3.6
22+
- pip
23+
run:
24+
- python >=3.6
25+
- pandas
26+
- requests
27+
- pyyaml
28+
- packaging
29+
30+
test:
31+
imports:
32+
- sasctl
33+
commands:
34+
- pip check
35+
- sasctl --help
36+
requires:
37+
- pip
38+
39+
about:
40+
home: https://github.com/sassoftware/python-sasctl/
41+
summary: "Python package and CLI for user-friendly integration with SAS Viya"
42+
license: Apache-2.0
43+
license_file: LICENSE
44+
doc_url: https://sassoftware.github.io/python-sasctl/
45+
dev_url: https://github.com/sassoftware/python-sasctl/

.github/workflows/build-test-deploy.yml

Lines changed: 84 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,12 @@ jobs:
118118
name: html-docs
119119
path: ./docs/_build/html
120120

121-
build:
122-
name: "Build Package"
121+
# Build a package for distribution through PyPI.org (pip install sasctl)
122+
build_pypi:
123+
name: "Build PyPI Package"
123124
runs-on: ubuntu-latest
124125
needs: test
125-
if: startsWith(github.ref, 'refs/tags/') # run only on tagged commits
126+
if: startsWith(github.ref, 'refs/tags/') # run only on tagged commits
126127

127128
steps:
128129
- name: Checkout repository
@@ -158,38 +159,74 @@ jobs:
158159
159160
- name: Archive distribution artifacts
160161
# Archive distribution files for use by auto (or manual) PyPI upload
161-
uses: actions/upload-artifact@v2
162+
uses: actions/upload-artifact@v3
162163
with:
163164
name: pypi-dist
164165
path: ./dist
165166

166167
- name: Archive changelog artifacts
167-
uses: actions/upload-artifact@v2
168+
uses: actions/upload-artifact@v3
168169
with:
169170
name: release_notes
170171
path: release_notes.md
171172

173+
# Build a package for distribution through Anaconda.org (conda install sasctl)
174+
build_conda:
175+
name: "Build Conda Package"
176+
runs-on: ubuntu-latest
177+
needs: test
178+
if: startsWith(github.ref, 'refs/tags/') # run only on tagged commits
179+
180+
steps:
181+
# Setup Miniconda
182+
- uses: conda-incubator/setup-miniconda@v2
183+
with:
184+
auto-update-conda: true
185+
186+
- name: Install conda-build
187+
shell: bash -l {0}
188+
run: |
189+
conda install conda-build
190+
191+
- name: Checkout repository
192+
uses: actions/checkout@v3
172193

194+
# Build package and store results in .build folder
195+
- name: Build package
196+
shell: bash -l {0}
197+
run: |
198+
conda build --output-folder .build .conda
199+
200+
# Archive distribution files. Will upload in a downstream job.
201+
- name: Archive distribution artifacts
202+
uses: actions/upload-artifact@v3
203+
with:
204+
name: conda-dist
205+
path: .build
206+
207+
208+
# Publishes the new package to PyPI, uploads the latest documentation to GitHub Pages
209+
# and creates a new release with change notes on GitHub.
173210
publish:
174211
name: "Publish"
175212
runs-on: ubuntu-latest
176-
needs: [gh-pages, build]
177-
steps:
213+
needs: [gh-pages, build_pypi, build_conda]
178214

215+
steps:
179216
- name: Download documentation
180-
uses: actions/download-artifact@v2
217+
uses: actions/download-artifact@v3
181218
with:
182219
name: html-docs
183220
path: ./html-docs
184221

185222
- name: Download release
186-
uses: actions/download-artifact@v2
223+
uses: actions/download-artifact@v3
187224
with:
188225
name: pypi-dist
189226
path: ./dist
190227

191228
- name: Download release notes
192-
uses: actions/download-artifact@v2
229+
uses: actions/download-artifact@v3
193230
with:
194231
name: release_notes
195232

@@ -199,6 +236,7 @@ jobs:
199236
- name: Display structure of downloaded files
200237
run: ls -R
201238

239+
# Create a draft release on GitHub
202240
- name: Create Release
203241
id: create_release
204242
uses: softprops/action-gh-release@v1
@@ -208,6 +246,7 @@ jobs:
208246
body: ""
209247
files: documentation.zip
210248

249+
# Publish the documentation to GitHub Pages
211250
- name: Deploy documentation
212251
uses: peaceiris/actions-gh-pages@v3
213252
with:
@@ -221,10 +260,45 @@ jobs:
221260
password: ${{ secrets.PYPI_API_TOKEN }}
222261
verbose: true
223262

263+
# Publish the release on GitHub (remove draft status)
224264
- name: Publish release
225265
uses: StuYarrow/publish-release@v1
226266
env:
227267
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
228268
with:
229269
id: ${{ steps.create_release.outputs.id }}
230270

271+
272+
# Uploads the package to Anaconda.
273+
# NOTE: could be merged with `publish` job above. Left as a separate, final job since it
274+
# involves multiple steps to setup the environment and if this job fails, the package
275+
# has already been made available through pip, and the release info published.
276+
upload_conda:
277+
name: "Upload Conda Package"
278+
runs-on: ubuntu-latest
279+
needs: [publish]
280+
281+
steps:
282+
# Setup Miniconda
283+
- uses: conda-incubator/setup-miniconda@v2
284+
with:
285+
auto-update-conda: true
286+
287+
# Setup Anaconda client (required for upload)
288+
- name: Install anaconda client
289+
shell: bash -l {0}
290+
run: |
291+
conda install anaconda-client
292+
293+
# Download release files
294+
- name: Download release
295+
uses: actions/download-artifact@v3
296+
with:
297+
name: conda-dist
298+
path: ./dist
299+
300+
# Upload release to Anaconda.org
301+
- name: Upload release
302+
shell: bash -l {0}
303+
run: |
304+
anaconda -t ${{ secrets.ANACONDA_TOKEN }} upload -u sas-institute ./dist/noarch/sasctl-*.tar.bz2

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ install the latest source code:
8686

8787
```pip install git+https://github.com/sassoftware/python-sasctl```
8888

89+
Alternatively, if you're using Anaconda you can install with:
90+
```
91+
conda install -c sas-institute sasctl
92+
```
8993

9094
## Getting Started
9195

0 commit comments

Comments
 (0)