diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..54660c7 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,14 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: +- package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: daily + time: "13:00" + commit-message: + prefix: "fix: " diff --git a/.github/renovate.json b/.github/renovate.json new file mode 100644 index 0000000..1cdbc81 --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,8 @@ +{ + "extends": [ + "config:base" + ], + "labels": [ + "bump:patch" + ] +} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..705406d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,58 @@ +name: release +on: + push: + branches: + - master + tags: + - 'v*.*.*' + pull_request: + types: + - labeled + +jobs: + release: + if: github.event.action != 'labeled' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + # Bump version on merging Pull Requests with specific labels. + # (bump:major,bump:minor,bump:patch) + - id: bumpr + if: "!startsWith(github.ref, 'refs/tags/')" + uses: haya14busa/action-bumpr@v1 + + # Update corresponding major and minor tag. + # e.g. Update v1 and v1.2 when releasing v1.2.3 + - uses: haya14busa/action-update-semver@v1 + if: "!steps.bumpr.outputs.skip" + with: + tag: ${{ steps.bumpr.outputs.next_version }} + + # Get tag name. + - id: tag + uses: haya14busa/action-cond@v1 + with: + cond: "${{ startsWith(github.ref, 'refs/tags/') }}" + if_true: ${{ github.ref }} + if_false: ${{ steps.bumpr.outputs.next_version }} + + # Create release. + - uses: shogo82148/actions-create-release@v1 + if: "steps.tag.outputs.value != ''" + with: + # This token is provided by Actions, you do not need to create your own token + github_token: ${{ secrets.GITHUB_TOKEN }} + tag_name: ${{ steps.tag.outputs.value }} + release_name: Release ${{ steps.tag.outputs.value }} + body: ${{ steps.bumpr.outputs.message }} + draft: false + prerelease: false + + release-check: + if: github.event.action == 'labeled' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Post bumpr status comment + uses: haya14busa/action-bumpr@v1 diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml new file mode 100644 index 0000000..d4941ec --- /dev/null +++ b/.github/workflows/reviewdog.yml @@ -0,0 +1,46 @@ +name: reviewdog +on: + push: + branches: + - master + pull_request: +jobs: + shellcheck: + name: runner / shellcheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: haya14busa/action-cond@v1 + id: reporter + with: + cond: ${{ github.event_name == 'pull_request' }} + if_true: "github-pr-review" + if_false: "github-check" + - uses: reviewdog/action-shellcheck@v1 + with: + github_token: ${{ secrets.github_token }} + reporter: ${{ steps.reporter.outputs.value }} + level: warning + + misspell: + name: runner / misspell + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: reviewdog/action-misspell@v1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-check + level: warning + locale: "US" + + alex: + name: runner / alex + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: reviewdog/action-alex@v1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-check + level: warning diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..13efeb9 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,29 @@ +name: Test +on: [] + +permissions: + contents: write + pull-requests: write + +jobs: + semver-check: + runs-on: ubuntu-latest + steps: + - uses: actions/setup-python@v4 + with: + python-version: 3.8 + - uses: actions/checkout@v3 + with: + repository: zckv/semantic-versioning-example + path: ./pyproject/ + fetch-depth: 0 + ref: revert_to_7.X + - uses: actions/checkout@v3 + with: + path: ./pyaction/ + # Test the action with no enabled steps. + - name: Test Action + uses: ./pyaction/ + with: + path: ./pyproject/ + base: revert_to_7.X diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..d0c562e --- /dev/null +++ b/action.yml @@ -0,0 +1,141 @@ +name: 'Semantic Release' +description: 'Use python semantic release 7 in a composite action. The result is pushed in a pull request, for repositories where the main branch is protected.' +author: 'Zackarie Vinckier ' + +inputs: + # Python Project Configuration is expected to be in a pyproject.toml + token: + description: 'GITHUB_TOKEN or a `repo` scoped Personal Access Token (PAT)' + default: ${{ github.token }} + path: + description: > + Relative path under $GITHUB_WORKSPACE to the repository. + Defaults to $GITHUB_WORKSPACE. + add-paths: + description: > + A comma or newline-separated list of file paths to commit. + Paths should follow git's pathspec syntax. + Defaults to adding all new and modified files. + commit-message: + description: 'The message to use when committing changes.' + default: '[create-pull-request] automated change' + committer: + description: > + The committer name and email address in the format `Display Name `. + Defaults to the GitHub Actions bot user. + default: 'GitHub ' + author: + description: > + The author name and email address in the format `Display Name `. + Defaults to the user who triggered the workflow run. + default: '${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>' + signoff: + description: 'Add `Signed-off-by` line by the committer at the end of the commit log message.' + default: false + branch: + description: 'The pull request branch name.' + default: 'create-pull-request/patch' + delete-branch: + description: > + Delete the `branch` when closing pull requests, and when undeleted after merging. + Recommend `true`. + default: false + branch-suffix: + description: 'The branch suffix type when using the alternative branching strategy.' + base: + description: > + The pull request base branch. + Defaults to the branch checked out in the workflow. + push-to-fork: + description: > + A fork of the checked out parent repository to which the pull request branch will be pushed. + e.g. `owner/repo-fork`. + The pull request will be created to merge the fork's branch into the parent's base. + title: + description: 'The title of the pull request.' + default: 'Changes by create-pull-request action' + body: + description: 'The body of the pull request.' + default: 'Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action' + body-path: + description: 'The path to a file containing the pull request body. Takes precedence over `body`.' + labels: + description: 'A comma or newline separated list of labels.' + assignees: + description: 'A comma or newline separated list of assignees (GitHub usernames).' + reviewers: + description: 'A comma or newline separated list of reviewers (GitHub usernames) to request a review from.' + team-reviewers: + description: > + A comma or newline separated list of GitHub teams to request a review from. + Note that a `repo` scoped Personal Access Token (PAT) may be required. + milestone: + description: 'The number of the milestone to associate the pull request with.' + draft: + description: 'Create a draft pull request. It is not possible to change draft status after creation except through the web interface' + default: false +runs: + using: "composite" + steps: + - name: Install semantic versionning + shell: bash + run: | + # The old 7.X version is needed + python -m pip install python-semantic-release==7.34.6 + - name: Use semver for commit + id: semver + shell: bash + env: + WPATH: ${{ inputs.path }} + AUTHOR: ${{ inputs.committer }} + GITHUB_WORKSPACE: ${{ github.workspace }} + BRANCH: ${{ inputs.base }} + run: | + export WPATH=${WPATH:=$GITHUB_WORKSPACE} + cd "$WPATH" + git switch $BRANCH + git config user.name $(echo $AUTHOR | cut -d ' ' -f1) + git config user.email $(echo $AUTHOR | cut -d ' ' -f2) + echo "old_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + semantic-release version -v DEBUG + echo "new_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + echo "msg=$(echo '"'$(git log -1 --pretty=%B)'"')" >> "$GITHUB_OUTPUT" + - name: Reset HEAD + shell: bash + if: ${{ steps.semver.outputs.old_sha != steps.semver.outputs.new_sha }} + env: + OLD_SHA: ${{ steps.semver.outputs.old_sha }} + WPATH: ${{ inputs.path }} + run: | + export WPATH=${WPATH:=$GITHUB_WORKSPACE} + cd "$WPATH" + git reset $OLD_SHA + - uses: peter-evans/create-pull-request@v5 + if: ${{ steps.semver.outputs.old_sha != steps.semver.outputs.new_sha }} + with: + token: ${{ inputs.token }} + path: ${{ inputs.path }} + add-paths: ${{ inputs.add-path }} + commit-message: ${{ steps.semver.outputs.msg }} + committer: ${{ inputs.committer }} + author: ${{ inputs.author }} + signoff: ${{ inputs.signoff }} + branch: ${{ inputs.branch }} + delete-branch: ${{ inputs.delete-branch }} + branch-suffix: ${{ inputs.branch-suffix }} + base: ${{ inputs.base }} + push-to-fork: ${{ inputs.push-to-fork }} + title: ${{ inputs.title }} + body: ${{ inputs.body }} + body-path: ${{ inputs.body-path }} + labels: ${{ inputs.labels }} + assignees: ${{ inputs.assignees }} + reviewers: ${{ inputs.reviewers }} + team-reviewers: ${{ inputs.team-reviewers }} + milestone: ${{ inputs.milestone }} + draft: ${{ inputs.draft }} + +# Ref: https://haya14busa.github.io/github-action-brandings/ +branding: + icon: 'check-circle' + color: 'green'