Skip to content

Commit

Permalink
fixes updateVersion and GHA
Browse files Browse the repository at this point in the history
Signed-off-by: pSchlarb <p.schlarb@esatus.com>
  • Loading branch information
pSchlarb committed Aug 26, 2022
1 parent ede5465 commit aa6dddb
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
publish-package:
name: Token Plugin Publish Packages
needs: [workflow-setup, build-package]
if: ${{ neees.workflow-setup.outputs.publish }}
if: ${{ needs.workflow-setup.outputs.publish }}
uses: ./.github/workflows/reuseable_publish.yaml
with:
GITHUB_REPOSITORY_NAME: ${{ needs.workflow-setup.outputs.GITHUB_REPOSITORY_NAME }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build/Dockerfile.ubuntu-2004
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 68DB5E88 \
libsodium23

# pypi based packages
RUN pip3 install -U \
RUN pip3 install -U \
Pygments==2.2.0 \
Pympler==0.8 \
PyNaCl==1.3.0 \
Expand Down
34 changes: 21 additions & 13 deletions .github/workflows/reuseable_build_package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,23 @@ on:
required: true
type: string
isDev:
required: false
default: true
type: boolean

jobs:
timestamp:
name: Get timestamp
runs-on: ubuntu-latest
outputs:
timestamp: ${{ steps.timestamp.outputs.timestamp }}
steps:
- id: timestamp
run: echo "::set-output name=timestamp::$(date +%s)"

build_token_plugin_release:
name: Token Plugin Build Packages
needs: timestamp
runs-on: ubuntu-20.04
container:
image: ghcr.io/${{ inputs.GITHUB_REPOSITORY_NAME }}/token-plugin-build:${{ inputs.UBUNTU_VERSION }}
Expand All @@ -24,6 +35,9 @@ jobs:
run: git config --global --add safe.directory $GITHUB_WORKSPACE
- name: Check out code
uses: actions/checkout@v3
- name: Set Version with UX-timestamp
if: ${{ inputs.isDev }}
run: python3 updateVersion.py --timestamp ${{ needs.timestamp.outputs.timestamp }}
- name: Build Token Plugin deployment package
run: |
mkdir -p /tmp/build-output
Expand All @@ -42,20 +56,17 @@ jobs:
path: /tmp/build-output/sovtokenfees_*.deb

build_sovtoken_pypi:
name: Token Plugin Build Packages
name: sovtoken Build Package
runs-on: ubuntu-20.04
needs: timestamp
container:
image: ghcr.io/${{ inputs.GITHUB_REPOSITORY_NAME }}/token-plugin-build:${{ inputs.UBUNTU_VERSION }}
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Set Version with UX-timestamp
if: ${{ inputs.isDev }}
run: python3 updateVersion.py
run: python3 updateVersion.py --timestamp ${{ needs.timestamp.outputs.timestamp }}
- name: Build python sovtoken package
run: python3 sovtoken/setup.py sdist --dist-dir /tmp/dist bdist_wheel --dist-dir /tmp/dist
- uses: actions/upload-artifact@v2
Expand All @@ -65,21 +76,18 @@ jobs:
retention-days: 5

build_sovtokenfees_pypi:
name: Token Plugin Build Packages
name: sovtokenfees Build Packages
runs-on: ubuntu-20.04
needs: timestamp
container:
image: ghcr.io/${{ inputs.GITHUB_REPOSITORY_NAME }}/token-plugin-build:${{ inputs.UBUNTU_VERSION }}
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Set Version with UX-timestamp
if: ${{ inputs.isDev }}
run: python3 updateVersion.py
- name: Build python sovtoken package
run: python3 updateVersion.py --timestamp ${{ needs.timestamp.outputs.timestamp }}
- name: Build python sovtokenfees package
run: python3 sovtokenfees/setup.py sdist --dist-dir /tmp/dist bdist_wheel --dist-dir /tmp/dist
- uses: actions/upload-artifact@v2
with:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
python-version: '3.8'
- name: Set up python
run: |
pip3 install semver
- name: Prepare package and set version
run: |
python3 updateVersion.py -t ${{ needs.taginfos.outputs.VERSION }}
Expand Down
16 changes: 8 additions & 8 deletions updateVersion.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import argparse
import json
import time
import semver

ap = argparse.ArgumentParser("Updates Version in json")

ap.add_argument("-t", "--tag", help="Version to be set to",)
ap.add_argument("--timestamp", help="Timestamp to be set for the version",)
args = vars(ap.parse_args())


Expand All @@ -15,15 +15,12 @@ def updateWithTag(ver):
return ver


def updateWithTimestamp():
uxtimestamp = str(int(time.time()))
def updateWithTimestamp(timestamp):
version = "str"
with open('sovtoken/sovtoken/metadata.json', 'r') as f:
data = json.load(f)
v = semver.VersionInfo.parse(data["version"])
print(v)
v = v.replace(prerelease="dev" + uxtimestamp)
print(v)
v = v.replace(prerelease="dev" + timestamp)
version = str(v)
return version

Expand All @@ -34,8 +31,11 @@ def updateWithTimestamp():
version = updateWithTag(args['tag'])
print("Version will be updated to: " + version)
else:
version = updateWithTimestamp()
print("Replacing Dev-Version with UX-timestamp: " + version)
if args['timestamp'] is not None:
version = updateWithTimestamp(args['timestamp'])
print("Replacing Dev-Version with UX-timestamp: " + version)
else:
raise ValueError("Either timestamp or tag must be provided")

with open('sovtoken/sovtoken/metadata.json', 'r') as f:
data = json.load(f)
Expand Down

0 comments on commit aa6dddb

Please sign in to comment.