Skip to content

Commit

Permalink
publish workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dothinking committed May 28, 2022
1 parent 6aba921 commit 6619bbc
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 3 deletions.
118 changes: 118 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Create release and publish to Pypi when pushing tags

name: publish

# Trigger the workflow on push tags, matching vM.n.p, i.e. v3.2.10
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

# Jobs to do:
# - build package
# - create release with asset
# - publish to Pypi
jobs:

# -----------------------------------------------------------
# create python env and setup package
# -----------------------------------------------------------
build:

# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Set up Python 3.x
uses: actions/setup-python@v1
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
# build package for tags, e.g. 3.2.1 extracted from 'refs/tags/v3.2.1'
- name: Build package
run: |
echo ${GITHUB_REF#refs/tags/v} > version.txt
python setup.py sdist --formats=gztar,zip
python setup.py bdist_wheel
# upload the artifacts for further jobs
# - app-tag.tar.gz
# - app-tag.zip
# - app-tag-info.whl
- name: Archive package
uses: actions/upload-artifact@v2
with:
name: dist
path: ./dist

# -----------------------------------------------------------
# create release and upload asset
# -----------------------------------------------------------
release:
runs-on: ubuntu-latest

# Run this job after build completes successfully
needs: build

steps:
- name: Checkout code
uses: actions/checkout@v2

# download artifacts from job: build
- name: Download artifacts from build
uses: actions/download-artifact@v2
with:
name: dist
path: dist

# create release and upload assets
- name: Create release with assets
uses: softprops/action-gh-release@v1
with:
files: |
./dist/*.tar.gz
./dist/*.zip
./dist/*.whl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


# -----------------------------------------------------------
# publish to Pypi
# -----------------------------------------------------------
publish:
runs-on: ubuntu-latest

# Run this job after both build and release completes successfully
needs: [build, release]

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Download artifacts from release
uses: actions/download-artifact@v2
with:
name: dist
path: dist

# Error when two sdist files created in build job are uploaded to Pipi:
# HTTPError: 400 Bad Request from https://upload.pypi.org/legacy/
# Only one sdist may be uploaded per release.
- name: Remove duplicated sdist
run: rm ./dist/*.zip

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_PASSWORD }}
12 changes: 11 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
recursive-include pyaddin/res *
include *.md
include LICENSE
include requirements.txt
include add-in.png

include pyaddin/resources/main.py
include pyaddin/resources/main.cfg
include pyaddin/resources/CustomUI.xml
recursive-include pyaddin/resources/scripts *.py
recursive-include pyaddin/resources/vba *
recursive-include pyaddin/resources/xlam *
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
中文 | [English](./README_CN.md)
[English](README.md) | Chinese

# PyAddin

Expand Down
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[中文](./README_CN.md) | English
English | [Chinese](README_CN.md)


# PyAddin

Expand Down

0 comments on commit 6619bbc

Please sign in to comment.