Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/utils/requirements_ci.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pre-commit ~=4.5
12 changes: 7 additions & 5 deletions .github/utils/update_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ echo -e "\n### Setting commit user ###"
git config --global user.email "${GIT_USER_EMAIL}"
git config --global user.name "${GIT_USER_NAME}"

echo -e "\n### Update version in README ###"
invoke update-version --version="${GITHUB_REF#refs/tags/}"
ref=${GITHUB_REF#refs/tags/}

echo -e "\n### Update version to ${ref} ###"
invoke update-version --version="${ref}"

echo -e "\n### Commit update ###"
git add push_action/__init__.py
git add CHANGELOG.md
git commit -m "Release ${GITHUB_REF#refs/tags/}"
git commit -m "Release ${ref}"

echo -e "\n### Create new full version (v<MAJOR>.<MINOR>.<PATCH>) tag ###"
TAG_MSG=.github/utils/release_tag_msg.txt
sed -i "s|TAG_NAME|${GITHUB_REF#refs/tags/}|g" "${TAG_MSG}"
sed -i "s|TAG_NAME|${ref}|g" "${TAG_MSG}"

git tag -af -F "${TAG_MSG}" ${GITHUB_REF#refs/tags/}
git tag -af -F "${TAG_MSG}" ${ref}

echo -e "\n### Move/update v<MAJOR> tag ###"
MAJOR_VERSION=$( echo ${GITHUB_REF#refs/tags/v} | cut -d "." -f 1 )
Expand Down
32 changes: 16 additions & 16 deletions .github/workflows/cd_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ env:
PUBLISH_UPDATE_BRANCH: main
GIT_USER_NAME: CasperWA
GIT_USER_EMAIL: "casper+github@welzel.nu"
EXCLUDE_TAGS_REGEX: "^(ci_test|master|v[0-9]+)$"

jobs:
update-repo-and-release:
Expand All @@ -18,27 +19,26 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Set up Python 3.11
uses: actions/setup-python@v5
- name: Set up Python 3.12
uses: actions/setup-python@v6
with:
python-version: '3.11'
python-version: '3.12'

- name: Install Python dependencies
run: |
python -m pip install -U pip
pip install -U setuptools wheel
pip install -U -e .[dev]
pip install .[dev]
pip install flit

- name: Update changelog
uses: CharMixer/auto-changelog-action@v1
uses: docker://githubchangeloggenerator/github-changelog-generator:1.16.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
release_branch: ${{ env.PUBLISH_UPDATE_BRANCH }}
exclude_tags_regex: "^(ci_test|master|v[0-9]+)$"
args: --user "CasperWA" --project push-protected --token "${{ secrets.GITHUB_TOKEN }}" --release-branch "${{ env.PUBLISH_UPDATE_BRANCH }}" --exclude-tags-regex "${{ env.EXCLUDE_TAGS_REGEX }}"

- name: Update version and tags
run: .github/utils/update_version.sh
Expand All @@ -54,16 +54,16 @@ jobs:
tags: true

- name: Get tagged versions
run: echo "PREVIOUS_VERSION=$(git tag -l --sort -version:refname | sed -n 2p)" >> $GITHUB_ENV
id: tagged_versions
run: |
PREVIOUS_VERSION="$(git tag -l --sort -version:refname | grep -v -e "${{ env.EXCLUDE_TAGS_REGEX }}" | sed -n 2p)"

echo "since_previous_version=--since-tag=${PREVIOUS_VERSION}" >> $GITHUB_OUTPUT

- name: Create release-specific changelog
uses: CharMixer/auto-changelog-action@v1
uses: docker://githubchangeloggenerator/github-changelog-generator:1.16.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
release_branch: ${{ env.PUBLISH_UPDATE_BRANCH }}
since_tag: "${{ env.PREVIOUS_VERSION }}"
output: "release_changelog.md"
exclude_tags_regex: "^(ci_test|master|v[0-9]+)$"
args: --user "CasperWA" --project push-protected --token "${{ secrets.GITHUB_TOKEN }}" --release-branch "${{ env.PUBLISH_UPDATE_BRANCH }}" ${{ steps.tagged_versions.outputs.since_previous_version }} --output release_changelog.md --usernames-as-github-logins --exclude-tags-regex "${{ env.EXCLUDE_TAGS_REGEX }}"

- name: Append changelog to release body
run: |
Expand Down
13 changes: 3 additions & 10 deletions .github/workflows/ci_dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,16 @@ jobs:
with:
ref: main

- name: Set up Python 3.11
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'

- name: Install `pre-commit`
run: |
python -m pip install -U pip
pip install -U setuptools wheel

while IFS="" read -r line || [ -n "${line}" ]; do
if [[ "${line}" =~ ^pre-commit.*$ ]]; then
pre_commit="${line}"
fi
done < requirements_dev.txt

pip install ${pre_commit}
pip install -r .github/utils/requirements_ci.txt

- name: Set up git user info
run: |
Expand Down
50 changes: 6 additions & 44 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
token: ${{ secrets.CI_RESET_TEST_BRANCHES }}
fetch-depth: 0

- name: Set up Python 3.11
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'

- name: Reset branches
run: |
Expand Down Expand Up @@ -292,54 +292,16 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python 3.11
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U setuptools wheel

while IFS="" read -r line || [ -n "${line}" ]; do
if [[ "${line}" =~ ^pre-commit.*$ ]]; then
pre_commit="${line}"
fi
done < requirements_dev.txt

pip install ${pre_commit}
pip install -r .github/utils/requirements_ci.txt

- name: Test with pre-commit
run: SKIP=pylint pre-commit run --all-files --show-diff-on-failure

pylint-safety:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install -U pip
pip install -U setuptools wheel
pip install -U -r requirements.txt -r requirements_dev.txt
pip install safety

- name: Run pylint
run: pylint --rcfile=pyproject.toml *.py push_action

# ID: 70612
# Package: Jinja2
# Has been disputed by the maintainer and multiple third parties.
# For more information see: https://github.com/advisories/GHSA-f6pv-j8mr-w6rr
- name: Run safety
run: pip freeze | safety check --stdin --ignore=70612
run: pre-commit run --all-files --show-diff-on-failure
14 changes: 2 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
default_language_version:
python: python3.11
python: python3.12

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -20,7 +20,7 @@ repos:
rev: v3.20.0
hooks:
- id: pyupgrade
args: [--py311-plus]
args: [--py312-plus]

- repo: https://github.com/ambv/black
rev: 25.1.0
Expand All @@ -41,13 +41,3 @@ repos:
additional_dependencies:
- "types-requests"
- "types-simplejson"

- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: python
types: [python]
require_serial: true
exclude: ^tests/.*$
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:3.11-alpine
FROM python:3.12-alpine

COPY README.md setup.py requirements*.txt ./
COPY LICENSE README.md pyproject.toml ./
COPY push_action ./push_action

RUN apk update \
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020-2021 Casper Welzel Andersen
Copyright (c) 2020-2025 Casper Welzel Andersen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
46 changes: 38 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,44 @@
[build-system]
requires = ["flit-core>=3.11,<4"]
build-backend = "flit_core.buildapi"

[project]
name="push-action"
dynamic = ["version"]
authors = [{name = "Casper Welzel Andersen", email = "casper+github@welzel.nu"}]
description = "Push local workflow commit(s) to protected branches with required status checks."
readme = "README.md"
license = {file = "LICENSE"}
classifiers = [
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
]
requires-python = ">=3.12,<3.13"

dependencies = [
"requests ~=2.32",
]

[project.optional-dependencies]
dev = [
"invoke ~=2.2",
"pre-commit ~=4.2",
"pylint ~=3.3",
]

[project.scripts]
push-action = "push_action.run:main"

[tool.flit.module]
name = "push_action"

[tool.mypy]
python_version = "3.11"
python_version = "3.12"
ignore_missing_imports = true
scripts_are_modules = true
warn_unused_configs = true
show_error_codes = true
allow_redefinition = true

[tool.pylint.messages_control]
max-line-length = 90
disable = [
# "duplicate-code",
# "no-name-in-module"
]
1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.

3 changes: 0 additions & 3 deletions requirements_dev.txt

This file was deleted.

50 changes: 0 additions & 50 deletions setup.py

This file was deleted.