Skip to content

Commit

Permalink
Fix job dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
nhuet committed Sep 13, 2022
1 parent d2a9854 commit 9bcfcdf
Showing 1 changed file with 44 additions and 23 deletions.
67 changes: 44 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build discrete-optimization
name: Build workflow-testing

on:
push:
Expand All @@ -15,44 +15,65 @@ concurrency:
cancel-in-progress: true

jobs:
test-github-env:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: test
run: |
echo ${{ github.workflow }}-${{ github.ref }}
echo $GITHUB_REF
echo ${{ github.ref }}
echo ${{ github.ref_name }}
echo ${{ github.head_ref }}
echo ${{ github.base_ref }}
echo ${{ github.repository }}
echo $GITHUB_REPOSITORY
echo ${{ github }}
- name: Install build dependencies
run: pip install -U setuptools wheel
- name: Update version number, according to pushed tag or `git describe`
run: |
# pushing tag or branch?
if [[ $GITHUB_REF == refs/tags/v* ]];
then
# pushing tag: ensure using the tag pushed
DESCRIBE=${GITHUB_REF/refs\/tags\//} # stripping "refs/tags/"
else
# default: use git describe from previous tag matching *glob* pattern "v[0-9]*"
DESCRIBE=$(git describe --tags --match="v[0-9]*")
fi
VERSION=${DESCRIBE/v/} # stripping "v"
echo $VERSION
# Replace in-place version number in package __init__.py, also used by setup.py
sed -i -e "s/^__version__\s*=.*$/__version__ = \"${VERSION}\"/g" workflow_testing/__init__.py
cat workflow_testing/__init__.py
- name: Build workflow_testing wheel
run: python setup.py bdist_wheel
- name: Upload as build artifacts
uses: actions/upload-artifact@v2
with:
name: wheels
path: dist/*.whl

deploy:
runs-on: ubuntu-latest
needs: test-github-env
needs: build
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: install build dependencies
run: pip install -U setuptools wheel
- name: Build workflow-testing wheel
run: python setup.py bdist_wheel
- name: rename dist as wheels
run: mv dist wheels
- name: Download wheels artifact
uses: actions/download-artifact@v1.0.0
with:
name: wheels
- name: Create the github release
uses: softprops/action-gh-release@v1
with:
files: wheels/*.whl
generate_release_notes: true
- name: Publish package to TestPyPI
- name: Publish package to TestPyPI (only for forks)
env:
TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
if: github.repository != 'airbus/workflow_testing' && env.TEST_PYPI_API_TOKEN != ''
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
packages_dir: wheels/
- name: Publish package to PyPI (main repo)
env:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
if: github.repository == 'airbus/workflow_testing' && env.PYPI_API_TOKEN != ''
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: wheels/

0 comments on commit 9bcfcdf

Please sign in to comment.