Skip to content

Commit

Permalink
publish to testpypi
Browse files Browse the repository at this point in the history
Signed-off-by: Philipp Schlarb <[email protected]>
  • Loading branch information
pSchlarb committed Mar 8, 2022
1 parent 8650ccd commit c4ac973
Show file tree
Hide file tree
Showing 2 changed files with 180 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/publishtestpypi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: "Publish Artifacts to pypi"

on:
workflow_call:
inputs:
GITHUB_REF:
required: true
type: string
UBUNTU_VERSION:
required: true
type: string
distribution:
required: true
type: string
secrets:
PYPI_API_TOKEN:
required: true


jobs:
publish_artifacts:
name: Publish Artifacts
runs-on: ubuntu-20.04
env:
GITHUB_REF: ${{ inputs.GITHUB_REF }}
UBUNTU_VERSION: ${{ inputs.UBUNTU_VERSION }}
steps:
- name: Check out code
uses: actions/checkout@v1

- name: Download Python Packages from Pipeline Artifacts
uses: actions/download-artifact@v2
with:
name: plenum-python
path: dist

- name: Publish Python Package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
skip_existing: true
repository_url: https://test.pypi.org/legacy/

136 changes: 136 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,140 @@ jobs:
- name: Teststepif
if: ${{ github.event.release.prerelease == true }}
run: echo "Prerelease checked true"

workflow-setup:
name: Initialize Workflow
runs-on: ubuntu-latest
outputs:
CACHE_KEY_BUILD: ${{ steps.cache.outputs.CACHE_KEY_BUILD }}
UBUNTU_VERSION: ${{ steps.cache.outputs.UBUNTU_VERSION }}
# Expose the lowercase version of the GitHub repository name
# to all subsequent jobs that reference image repositories
# as the push and pull operations require the URL of the repository
# to be in lowercase.
GITHUB_REPOSITORY_NAME: ${{ steps.repository-name.outputs.lowercase }}
GITHUB_REF: ${{ steps.cache.outputs.GITHUB_REF }}
distribution: ${{ steps.cache.outputs.distribution }}
isDev: ${{ steps.build-flags.outputs.isDev }}
isRC: ${{ steps.build-flags.outputs.isRC }}
publish: ${{ steps.build-flags.outputs.publish }}
steps:
- name: Git checkout
uses: actions/checkout@v2

- name: Convert the GitHub repository name to lowercase
id: repository-name
uses: ASzc/change-string-case-action@v1
with:
string: ${{ github.repository }}

- name: Set outputs
id: cache
run: |
echo "::set-output name=CACHE_KEY_BUILD::${{ hashFiles('.github/workflows/build/Dockerfile.ubuntu-2004') }}"
echo "::set-output name=UBUNTU_VERSION::ubuntu-2004"
echo "::set-output name=distribution::focal"
if [[ "${{github.base_ref}}" == 'master' || "${{github.ref}}" == 'refs/heads/master' || "${{github.base_ref}}" == 'main' || "${{github.ref}}" == 'refs/heads/main' ]]; then
echo "::set-output name=GITHUB_REF::main"
elif [[ ${{ github.event.release.prerelease }} == 'true' ]]; then
echo "::set-output name=GITHUB_REF::rc"
elif [[ ${{ github.event.release.prerelease }} == 'false' ]]; then
echo "::set-output name=GITHUB_REF::stable"
else
echo "::set-output name=GITHUB_REF::dev"
fi
# Test output
echo "${{steps.cache.outputs.GITHUB_REF}}"
- name: Set build flags
id: build-flags
run: |
if [[ "${{steps.cache.outputs.GITHUB_REF}}" == 'dev' || "${{steps.cache.outputs.GITHUB_REF}}" == 'main' ]]; then
echo "::set-output name=isDev::true"
else
echo "::set-output name=isDev::false"
fi
if [[ "${{steps.cache.outputs.GITHUB_REF}}" == 'rc' ]]; then
echo "::set-output name=isRC::true"
else
echo "::set-output name=isRC::false"
fi
# # Ensure publishing is only performed when the build is executed from the main (hyperledger/indy-plenum) repository.
# if [[ ${{github.event.repository.full_name}} == 'hyperledger/indy-plenum' && ${{github.event_name}} == 'push' && ( ${{steps.cache.outputs.GITHUB_REF}} == 'main' || ${{steps.cache.outputs.GITHUB_REF}} == 'rc' || ${{steps.cache.outputs.GITHUB_REF}} == 'stable' || ${{steps.cache.outputs.GITHUB_REF}} == 'dev' ) ]]; then
# echo "::set-output name=publish::true"
# else
# echo "::set-output name=publish::false"
# fi
echo "::set-output name=publish::true"
# lint:
# name: Lint
# needs: [workflow-setup]
# runs-on: ubuntu-20.04
# steps:
# - name: Check out code
# uses: actions/checkout@v2
# - name: Set up Python
# uses: actions/setup-python@v2
# with:
# python-version: '3.8'
# - uses: actions/cache@v2
# with:
# path: ~/.cache/pip
# key: ${{ runner.os }}-pip-lint
# restore-keys: |
# ${{ runner.os }}-pip-lint
# - name: Install flake8
# run: pip install flake8==3.8.4 pep8==1.7.1 pep8-naming==0.6.1
# - name: Lint with flake8
# run: python3 -m flake8 .


build-docker-image:
name: Create Builder Image
needs: [workflow-setup]
uses: ./.github/workflows/buildimage.yaml
with:
CACHE_KEY_BUILD: ${{ needs.workflow-setup.outputs.CACHE_KEY_BUILD }}
GITHUB_REPOSITORY_NAME: ${{ needs.workflow-setup.outputs.GITHUB_REPOSITORY_NAME }}
UBUNTU_VERSION: ${{ needs.workflow-setup.outputs.UBUNTU_VERSION }}

# plenum_tests:
# name: Test Plenum
# needs: [workflow-setup, lint, build-docker-image]
# uses: ./.github/workflows/test.yaml
# with:
# GITHUB_REPOSITORY_NAME: ${{ needs.workflow-setup.outputs.GITHUB_REPOSITORY_NAME }}
# UBUNTU_VERSION: ${{ needs.workflow-setup.outputs.UBUNTU_VERSION }}

build_packages:
name: Build Packages
needs: [workflow-setup, build-docker-image]
uses: ./.github/workflows/buildpackages.yaml
with:
GITHUB_REPOSITORY_NAME: ${{ needs.workflow-setup.outputs.GITHUB_REPOSITORY_NAME }}
UBUNTU_VERSION: ${{ needs.workflow-setup.outputs.UBUNTU_VERSION }}
isDev: ${{ needs.workflow-setup.outputs.isDev }}
isRC: ${{ needs.workflow-setup.outputs.isRC }}


publish_artifacts:
name: Publish Artifacts
needs: [workflow-setup, build_packages]
if: needs.workflow-setup.outputs.publish == 'true'
uses: ./.github/workflows/publishtestpypi.yaml
with:
GITHUB_REF: ${{ needs.workflow-setup.outputs.GITHUB_REF }}
UBUNTU_VERSION: ${{ needs.workflow-setup.outputs.UBUNTU_VERSION }}
distribution: ${{ needs.workflow-setup.outputs.distribution }}
secrets:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}

0 comments on commit c4ac973

Please sign in to comment.