diff --git a/.github/workflows/bump.yml b/.github/workflows/bump.yml new file mode 100644 index 0000000..99649cd --- /dev/null +++ b/.github/workflows/bump.yml @@ -0,0 +1,87 @@ +name: Bump package version +on: + workflow_dispatch: + inputs: + dry-run: + type: boolean + description: Only output new version number, no actual change. + required: false + rule: + type: choice + description: Version bump level + required: true + options: + - major + - minor + - patch + - premajor + - preminor + - prepatch + - prerelease + - "prerelease --next-phase" + + workflow_call: + inputs: + dry-run: + type: boolean + description: Only output new version number, no actual change. + required: false + rule: + type: string + description: Version bump level + required: true + outputs: + bumpmsg: + description: Message created by the version bump. + value: ${{ jobs.bump.outputs.bumpmsg }} + +jobs: + bump: + name: Bump version number + runs-on: ubuntu-latest + permissions: + contents: write + outputs: + bumpmsg: ${{ steps.bumping.outputs.BUMP_MSG }} + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + + - name: Set up Poetry + uses: abatilo/actions-poetry@v2 + with: + poetry-version: "1.7.0" + + - name: Bump package Version using Poetry + id: bumping + env: + RULE: ${{ inputs.rule }} + DRY: ${{ inputs.dry-run && '--dry-run' || '' }} + run: echo "BUMP_MSG=$(poetry version $DRY $RULE)" >> $GITHUB_OUTPUT + + - name: Output debug msg + if: inputs.dry-run + env: + BUMP_MSG: ${{ steps.bumping.outputs.BUMP_MSG }} + run: | + echo "## $BUMP_MSG" >> $GITHUB_STEP_SUMMARY + echo "Dry run only, no actual modification made." >> $GITHUB_STEP_SUMMARY + + - name: Commit changes + # could also use https://github.com/stefanzweifel/git-auto-commit-action instead + if: ${{ ! inputs.dry-run }} + env: + BUMP_MSG: ${{ steps.bumping.outputs.BUMP_MSG }} + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git commit -am "$BUMP_MSG" + git push + echo "## $BUMP_MSG" >> $GITHUB_STEP_SUMMARY + echo "Successfully committed and pushed version bump." >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index f38a007..8b6b793 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -31,10 +31,17 @@ jobs: name: distribution path: dist/ + - name: Upload release attachment + uses: shogo82148/actions-upload-release-asset@v1 + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: dist/* + publish: name: Publish package to PyPI runs-on: ubuntu-latest needs: build + if: needs.build.result == "success" steps: - name: Checkout code uses: actions/checkout@v4 @@ -60,16 +67,13 @@ jobs: POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} run: poetry publish - upload: - name: Upload dist to release + bump: + name: Bump to dev version runs-on: ubuntu-latest - needs: build + needs: publish + if: needs.publish.result == "success" steps: - - name: Retrieve distribution files - uses: actions/download-artifact@v3 + - name: Checkout code + uses: ./.github/workflows/bump.yml with: - name: distribution - path: dist/ - - - name: Upload release attachment - run: echo ${{ github.event.release.upload_url }} + rule: prerelease diff --git a/pyproject.toml b/pyproject.toml index a638912..5cbc41f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "prepipy" -version = "0.7.1a2" +version = "0.7.1a3" description = "Provides the ability to stretch and combine astronomical images from multiple bands into (RGB) colour images." authors = ["Fabian Haberhauer "] maintainers = ["teutoburg "]