diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 52c9dd9..a8d4fb2 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -6,6 +6,11 @@ on: - main paths: - 'setup.py' + pull_request: + branches: + - "main" + paths: + - 'setup.py' jobs: check-version-changed: @@ -18,18 +23,18 @@ jobs: - name: Check if version changed id: version-change run: | - VERSION_CHANGE=$(git diff $(git rev-parse HEAD~1) $(git rev-parse HEAD) -- setup.py | grep -e "^+.*version.*=" -e "^-.*version.*=" | wc -l) + VERSION_CHANGE=$(git diff HEAD^ HEAD -- setup.py | grep -e "^+.*version.*=" -e "^-.*version.*=" | wc -l) if [ "$VERSION_CHANGE" -eq 0 ]; then echo "Version not changed" - echo "version_changed=false" >> $GITHUB_ENV + echo "::set-output name=version_changed::false" else echo "Version changed" - echo "version_changed=true" >> $GITHUB_ENV + echo "::set-output name=version_changed::true" fi publish: needs: check-version-changed - if: ${{ env.version_changed == 'true' }} + if: needs.check-version-changed.outputs.version_changed == 'true' runs-on: ubuntu-latest steps: - name: Check out code diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8eb8fac..047cbf9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,6 +6,11 @@ on: - main paths: - 'setup.py' + pull_request: + branches: + - "main" + paths: + - 'setup.py' jobs: check-version-changed: @@ -18,18 +23,18 @@ jobs: - name: Check if version changed id: version-change run: | - VERSION_CHANGE=$(git diff $(git rev-parse HEAD~1) $(git rev-parse HEAD) -- setup.py | grep -e "^+.*version.*=" -e "^-.*version.*=" | wc -l) + VERSION_CHANGE=$(git diff HEAD^ HEAD -- setup.py | grep -e "^+.*version.*=" -e "^-.*version.*=" | wc -l) if [ "$VERSION_CHANGE" -eq 0 ]; then echo "Version not changed" - echo "version_changed=false" >> $GITHUB_ENV + echo "::set-output name=version_changed::false" else echo "Version changed" - echo "version_changed=true" >> $GITHUB_ENV + echo "::set-output name=version_changed::true" fi release: needs: check-version-changed - if: ${{ env.version_changed == 'true' }} + if: needs.check-version-changed.outputs.version_changed == 'true' runs-on: ubuntu-latest steps: - name: Checkout Repository @@ -41,17 +46,17 @@ jobs: - name: Extract Version from setup.py id: get_version run: | - echo "VERSION=$(python setup.py --version)" >> $GITHUB_ENV + echo "::set-output name=VERSION::$(python setup.py --version)" - name: Create and Push Tag run: | git config --local user.email "action@github.com" git config --local user.name "GitHub Action" - git tag v${{ env.VERSION }} - git push origin v${{ env.VERSION }} + git tag v${{ steps.get_version.outputs.VERSION }} + git push origin v${{ steps.get_version.outputs.VERSION }} - name: Create GitHub Release uses: softprops/action-gh-release@v1 with: - name: neuralnetlib v${{ env.VERSION }} - tag_name: v${{ env.VERSION }} + name: neuralnetlib v${{ steps.get_version.outputs.VERSION }} + tag_name: v${{ steps.get_version.outputs.VERSION }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/setup.py b/setup.py index fbf54d9..fb11289 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='neuralnetlib', - version='0.4.0', + version='0.3.1', author='Marc Pinet', description='A simple neural network library with only numpy as dependency', long_description=open('README.md', encoding="utf-8").read(),