Skip to content

Commit

Permalink
Merge pull request #36 from gisce/polsala-patch-1
Browse files Browse the repository at this point in the history
Update release.yml
  • Loading branch information
polsala authored Nov 28, 2023
2 parents 76b8762 + 8914f07 commit 80ac873
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[bumpversion]
current_version = 0.18.0
current_version = 0.18.1
41 changes: 21 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,46 @@
name: Release
name: Upload package to PYPI

on:
push:
tags:
- 'v[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+'
- 'v[0-9]+\.[0-9]+\.[0-9]+'

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false

permissions:
contents: write
discussions: write

jobs:
build:
runs-on: ubuntu-latest
upload-to-pypi:
runs-on: [self-hosted, Keroberos]
steps:
- uses: actions/checkout@v3
- name: Set up Python 2.7
run: |
sudo apt update
sudo apt install python2 python-pip
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 2
printf '1\n' | sudo update-alternatives --config python
cd /usr/bin
sudo ln -s /usr/bin/pip2 ./pip
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Get tag
id: tag
uses: dawidd6/action-get-tag@v1
with:
strip_v: false
- name: Run setup
run: |
python setup.py sdist

- name: Creating a realease/pre-release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{steps.tag.outputs.tag}}
draft: false
prerelease: ${{ contains(github.ref, '-rc') }}
generate_release_notes: true

- name: Publish a Python distribution to PyPI
if: ${{ contains(github.ref, '-rc') }} == false
uses: pypa/gh-action-pypi-publish@release/v1
uses: conchylicultor/pypi-build-publish@v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
pypi-token: ${{ secrets.PYPI_MASTER_TOKEN }}
69 changes: 44 additions & 25 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,58 @@
name: GISCE_POWERPROFILE_VERION
name: BUMP Version
on:
push:
# For copy pase proposes, change this variable
branches: [ master ]

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false

env:
# For copy pase proposes, change this variable
VERSION_FILE: setup.py
HOME: /home/ci_repos
SCRIPTS_PATH: /home/ci_repos/ci_scripts
USER: ci_repos

permissions:
actions: write
checks: write
contents: write
deployments: write
issues: write
pull-requests: write
statuses: read

jobs:
bump:
runs-on: ubuntu-latest
bump-version:
runs-on: [self-hosted, Keroberos]
if: ${{ !startsWith(github.event.head_commit.message, 'Bump to v') }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.SSH_PRIVATE }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Setup git
run: |
git config --global user.email "[email protected]"
git config --global user.name "giscegit"
- name: Install python packages
token: ${{ secrets.PUB_MASTER_PUSH_TOKEN }}
- name: Update python packages
run: |
pip install bump2version
pip install giscemultitools
. $SCRIPTS_PATH/load_pyenv.sh
pyenv activate bump
pip install --upgrade bump2version
pip install --upgrade giscemultitools
- name: Get PR info
env:
GITHUB_TOKEN: ${{ secrets.GH_GIT_TOKEN }}
WORKSPACE: ${{github.workspace}}
GITHUB_TOKEN: ${{ secrets.RO_GH_ACTIONS_TOKEN }}
run: |
. $SCRIPTS_PATH/load_pyenv.sh
pyenv activate bump
echo 'PR_INFO<<EOF' >> $GITHUB_ENV
gisce_github get-commits-sha-from-merge-commit --owner gisce --repository powerprofile --sha $GITHUB_SHA >> $GITHUB_ENV
gisce_github get-commits-sha-from-merge-commit --owner ${{ github.repository_owner }} --repository ${{ github.event.repository.name }} --sha ${{ github.sha }} >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Retrive info
env:
GITHUB_TOKEN: ${{ secrets.GH_GIT_TOKEN }}
- name: Bump Version
run: |
eval `ssh-agent -s`
ssh-add - <<< '${{ secrets.SSH_PRIVATE }}'
. $SCRIPTS_PATH/load_pyenv.sh
pyenv activate bump
pr_labels=$( echo '${{ env.PR_INFO }}' | jq -r '.pullRequest.labels' )
is_minor=false
is_major=false
Expand All @@ -58,6 +75,8 @@ jobs:
VERSION_TYPE="patch"
fi
if [[ $VERSION_TYPE != false ]]; then
bump2version $VERSION_TYPE --tag --commit -m "Bump to v{new_version}" setup.py
git config user.name Release Bot
git config user.email [email protected]
bump2version $VERSION_TYPE --tag --commit -m "Bump to v{new_version}" $VERSION_FILE
git push origin master --tags
fi
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name="powerprofile",
version="0.18.0",
version="0.18.1",
author="GISCE-TI, S.L.",
author_email="[email protected]",
description=("Library to manage power profiles"),
Expand Down

0 comments on commit 80ac873

Please sign in to comment.