diff --git a/.bumpversion.toml b/.bumpversion.toml index 070dbab..bbb618d 100644 --- a/.bumpversion.toml +++ b/.bumpversion.toml @@ -5,9 +5,6 @@ tag = true tag_name = "v{new_version}" current_version = "1.7.1" -[[tool.bumpversion.files]] -glob = "documentation/**/*.md" - [[tool.bumpversion.files]] glob = "*.md" @@ -19,3 +16,6 @@ filename = "pyproject.toml" [[tool.bumpversion.files]] filename = "documentation/getting_started_guide/requirements.txt" + +[[tool.bumpversion.files]] +glob = "documentation/DATA_FORMAT.md" diff --git a/.github/workflows/release-new-version.yml b/.github/workflows/release-new-version.yml new file mode 100644 index 0000000..4502361 --- /dev/null +++ b/.github/workflows/release-new-version.yml @@ -0,0 +1,99 @@ +name: Release new version + +run-name: Release new version with ${{ inputs.increment }} bump by @${{ github.actor }} + +on: + workflow_dispatch: + inputs: + increment: + description: "Semantic version increment to bump" + default: "patch" + options: + - major + - minor + - patch + required: true + type: choice + +permissions: {} + +jobs: + bump-version: + if: ${{ github.ref_name == github.event.repository.default_branch }} + runs-on: ubuntu-latest + outputs: + version-tag: ${{ steps.get-tag.outputs.VERSION_TAG }} + + permissions: + contents: write # required to push new tag to repo + + steps: + # Create a token so it can be used during checkout + push steps; it must + # be explicitly passed to steps that need it. + - name: Generate GitHub App token + id: app-token + uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 + with: + client-id: ${{ vars.APP_CLIENT_ID }} + private-key: ${{ secrets.APP_PRIVATE_KEY }} + permission-contents: write + + - name: Checkout the repo + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + fetch-depth: 0 # fetch full commit and tag history + token: ${{ steps.app-token.outputs.token }} + persist-credentials: false + + - name: Setup Python + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: "3.13" + + - name: Install dependencies + run: pip install -e '.[dev]' + + # Configure git before bumping version, since it makes a commit + - name: Configure git + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Bump version + run: bump-my-version bump -v ${BUMP_TYPE} + env: + BUMP_TYPE: ${{ inputs.increment }} + + - name: Get the new tag + id: get-tag + run: echo "VERSION_TAG=$(git describe --tags --abbrev=0)" >> "$GITHUB_OUTPUT" + + # The checkout action normally sets the git access token (via + # persist-credentials), but this can be unsafe! We explicitly set the + # token in the authorization header here, so that other steps don't have + # unintended access to the token. + - name: Push changes and new tag + run: | + git config http.extraheader "Authorization: Basic $(echo -n x-access-token:${GH_TOKEN} | base64 -w 0)" + git push origin ${DEFAULT_BRANCH} + git push origin ${VERSION_TAG} + git config --unset-all http.extraheader + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} + DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} + VERSION_TAG: ${{ steps.get-tag.outputs.VERSION_TAG }} + + create-draft-release: + if: ${{ github.ref_name == github.event.repository.default_branch }} + runs-on: ubuntu-latest + needs: [bump-version] + + permissions: + contents: write + + steps: + - name: Draft release + run: gh release create ${VERSION_TAG} --draft + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VERSION_TAG: ${{ needs.bump-version.outputs.version-tag }}