Compare commits
1 Commits
v0.0.1-dev
...
v0.0
| Author | SHA1 | Date | |
|---|---|---|---|
| bf30b4defe |
@@ -1 +1 @@
|
||||
version_descriptor: version.txt
|
||||
version_descriptor: pyproject.toml
|
||||
|
||||
10
.gitea/workflows/check-is-not-released.yaml
Normal file
10
.gitea/workflows/check-is-not-released.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
name: check if project is already released
|
||||
on:
|
||||
- pull_request
|
||||
|
||||
jobs:
|
||||
unittest:
|
||||
runs-on: action-runner
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./check-is-not-released
|
||||
@@ -23,17 +23,74 @@ jobs:
|
||||
|
||||
- run: set -u; echo "$RELEASE_PROJECT_CURRENT_VERSION"
|
||||
|
||||
test-declare-with-release-yaml:
|
||||
test-sync-versions:
|
||||
runs-on: action-runner
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# skip login locally
|
||||
- if: github.repository == 'actions/release'
|
||||
uses: https://gitea.puzzleyou.net/actions/configure-runner-environment@master
|
||||
|
||||
- run: |
|
||||
echo "1.33.7" > /tmp/version-test.txt
|
||||
echo "0.0.42" > /tmp/other-version.txt
|
||||
|
||||
- uses: ./declare
|
||||
with:
|
||||
configure_runner_environment: false
|
||||
filename: ./src/release/tests/assets/release.yaml
|
||||
version_descriptor: /tmp/version-test.txt
|
||||
artefact_type: oci_image
|
||||
artefact_name: default-image
|
||||
artefact_version_descriptor: /tmp/other-version.txt
|
||||
|
||||
- run: set -u; echo "$RELEASE_PROJECT_CURRENT_VERSION"
|
||||
- uses: ./sync-versions
|
||||
|
||||
- run: test "$(cat /tmp/version-test.txt)" = "$RELEASE_PROJECT_PLANNED_VERSION"
|
||||
- run: test "$(cat /tmp/other-version.txt)" = "$RELEASE_PROJECT_PLANNED_VERSION"
|
||||
|
||||
test-is-not-yet-released:
|
||||
runs-on: action-runner
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# skip login locally
|
||||
- if: github.repository == 'actions/release'
|
||||
uses: https://gitea.puzzleyou.net/actions/configure-runner-environment@master
|
||||
|
||||
- uses: ./declare
|
||||
with:
|
||||
configure_runner_environment: false
|
||||
version_descriptor: test-assets/version.txt
|
||||
|
||||
- uses: ./check-is-not-released
|
||||
with:
|
||||
configure_runner_environment: false
|
||||
|
||||
test-skip-release-if-already-released:
|
||||
runs-on: action-runner
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# skip login locally
|
||||
- if: github.repository == 'actions/release'
|
||||
uses: https://gitea.puzzleyou.net/actions/configure-runner-environment@master
|
||||
|
||||
- uses: ./declare
|
||||
with:
|
||||
configure_runner_environment: false
|
||||
version_descriptor: test-assets/Cargo.toml
|
||||
|
||||
- uses: ./release
|
||||
with:
|
||||
configure_runner_environment: false
|
||||
dry_run: true
|
||||
sync_versions: false
|
||||
|
||||
test-declare-with-release-yaml:
|
||||
runs-on: action-runner
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# skip login locally
|
||||
- if: github.repository == 'actions/release'
|
||||
@@ -42,6 +99,10 @@ jobs:
|
||||
- uses: ./release
|
||||
with:
|
||||
dry_run: true
|
||||
configure_runner_environment: false
|
||||
sync_versions: false
|
||||
|
||||
- run: set -u; echo "$RELEASE_PROJECT_CURRENT_VERSION"
|
||||
|
||||
test-declare-directly:
|
||||
runs-on: action-runner
|
||||
@@ -74,7 +135,7 @@ jobs:
|
||||
- uses: ./add-artefact
|
||||
with:
|
||||
type: wheel
|
||||
pattern: "test-assets/wheels/*.whl"
|
||||
filename: "test-assets/wheels/*.whl"
|
||||
|
||||
- uses: ./add-artefact
|
||||
with:
|
||||
@@ -95,12 +156,21 @@ jobs:
|
||||
repository: europe-docker.hetzner.cloud/puzzleyou/helm
|
||||
condition: always
|
||||
|
||||
- name: ensure that environment variables are set
|
||||
- name: ensure that default artefact is set
|
||||
run: env | grep "RELEASE_IMAGE_LOCAL_NAME_DEFAULT_IMAGE"
|
||||
|
||||
- name: ensure that additional artefact is set
|
||||
run: env | grep "RELEASE_IMAGE_LOCAL_NAME_SOME_DOCKER_IMAGE"
|
||||
|
||||
- name: dump release environment variables
|
||||
run: env | grep "RELEASE_"
|
||||
|
||||
- name: check version
|
||||
run: echo "$RELEASE_PROJECT_CURRENT_VERSION" | grep "1.33.7"
|
||||
|
||||
- name: check state file is set
|
||||
run: set -u; echo "$RELEASE_ACTION_STATEFILE"
|
||||
|
||||
- name: dump project description
|
||||
uses: ./dump
|
||||
|
||||
|
||||
@@ -14,5 +14,4 @@ jobs:
|
||||
runs-on: action-runner
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./declare # TODO single action
|
||||
- uses: ./release
|
||||
- uses: ./
|
||||
|
||||
1
action.yaml
Symbolic link
1
action.yaml
Symbolic link
@@ -0,0 +1 @@
|
||||
release/action.yaml
|
||||
@@ -18,7 +18,7 @@ inputs:
|
||||
|
||||
filename:
|
||||
required: false
|
||||
description: "required for tarball, sdist"
|
||||
description: "required for tarball, sdist, wheel"
|
||||
default: ""
|
||||
|
||||
package_name:
|
||||
@@ -26,11 +26,6 @@ inputs:
|
||||
description: "required for tarball"
|
||||
default: ""
|
||||
|
||||
pattern:
|
||||
required: false
|
||||
description: "required for wheel"
|
||||
default: ""
|
||||
|
||||
directory:
|
||||
required: false
|
||||
description: "required for npm"
|
||||
@@ -46,7 +41,7 @@ runs:
|
||||
steps:
|
||||
- name: add artefact
|
||||
run: |
|
||||
nix run . -- \
|
||||
nix run ${{ github.action_path }} -- \
|
||||
add-artefact \
|
||||
--state "${RELEASE_ACTION_STATEFILE}" \
|
||||
--artefact-type "${{ inputs.type }}" \
|
||||
@@ -54,7 +49,6 @@ runs:
|
||||
--artefact-name "${{ inputs.name }}" \
|
||||
--artefact-filename "${{ inputs.filename }}" \
|
||||
--artefact-package-name "${{ inputs.package_name }}" \
|
||||
--artefact-pattern "${{ inputs.pattern }}" \
|
||||
--artefact-directory "${{ inputs.directory }}" \
|
||||
--version-descriptor "${{ inputs.version_descriptor }}" \
|
||||
--write-env-vars-to-filename "$GITHUB_ENV"
|
||||
|
||||
@@ -38,7 +38,7 @@ runs:
|
||||
steps:
|
||||
- name: add deployment
|
||||
run: |
|
||||
nix run . -- \
|
||||
nix run ${{ github.action_path }} -- \
|
||||
add-deployment \
|
||||
--state "${RELEASE_ACTION_STATEFILE}" \
|
||||
--deployment-type "${{ inputs.type }}" \
|
||||
|
||||
44
check-is-not-released/action.yaml
Normal file
44
check-is-not-released/action.yaml
Normal file
@@ -0,0 +1,44 @@
|
||||
name: "check not released"
|
||||
description: "ensure that there is no release with the current version"
|
||||
|
||||
inputs:
|
||||
configure_runner_environment:
|
||||
required: false
|
||||
default: true
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- if: inputs.configure_runner_environment == 'true'
|
||||
uses: https://gitea.puzzleyou.net/actions/configure-runner-environment@master
|
||||
|
||||
- name: declare project if neccessary
|
||||
run: |
|
||||
if [[ ! -z "${RELEASE_PROJECT_CURRENT_VERSION}" ]]; then
|
||||
echo "already set up."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
nix run ${{ github.action_path }} -- \
|
||||
declare \
|
||||
--release-yaml-filename ".gitea/release.yaml" \
|
||||
--gitea-instance "https://gitea.puzzleyou.net" \
|
||||
--release-repository-name "${{ github.repository }}" \
|
||||
--release-ref-name "${{ github.ref_name }}" \
|
||||
--release-run-number "${{ github.run_number }}" \
|
||||
--release-commit-sha "${{ github.sha }}" \
|
||||
--write-env-vars-to-filename "$GITHUB_ENV"
|
||||
|
||||
- name: check release state
|
||||
run: |
|
||||
set +e
|
||||
|
||||
if [[ "$RELEASE_PROJECT_IS_RELEASED" = "1" ]]; then
|
||||
VERSION="$RELEASE_PROJECT_CURRENT_VERSION"
|
||||
echo "Project is already released with version ${VERSION}."
|
||||
echo "You should increment the project version."
|
||||
echo "If you don't, then the project will not be released."
|
||||
exit -1
|
||||
else
|
||||
echo "Project is not yet released."
|
||||
fi
|
||||
@@ -41,7 +41,7 @@ inputs:
|
||||
|
||||
artefact_filename:
|
||||
required: false
|
||||
description: "required for tarball, sdist"
|
||||
description: "required for tarball, sdist, wheel"
|
||||
default: ""
|
||||
|
||||
artefact_package_name:
|
||||
@@ -49,11 +49,6 @@ inputs:
|
||||
description: "required for tarball"
|
||||
default: ""
|
||||
|
||||
artefact_pattern:
|
||||
required: false
|
||||
description: "required for wheel"
|
||||
default: ""
|
||||
|
||||
artefact_directory:
|
||||
required: false
|
||||
description: "required for npm"
|
||||
@@ -102,60 +97,26 @@ runs:
|
||||
- if: inputs.configure_runner_environment == 'true'
|
||||
uses: https://gitea.puzzleyou.net/actions/configure-runner-environment@master
|
||||
|
||||
- name: init action state
|
||||
run: |
|
||||
RELEASE_ACTION_STATEFILE=$(mktemp)
|
||||
echo "[release] statefile: $RELEASE_ACTION_STATEFILE"
|
||||
echo "RELEASE_ACTION_STATEFILE="$RELEASE_ACTION_STATEFILE"" \
|
||||
>> "$GITHUB_ENV"
|
||||
|
||||
- name: declare release project
|
||||
if: inputs.version_descriptor == ''
|
||||
run: |
|
||||
if [[ "${{ github.ref_name }}" == "master" || "${{ github.ref_name }}" == "main" ]]; then
|
||||
IS_PRE_RELEASE="0"
|
||||
else
|
||||
IS_PRE_RELEASE="1"
|
||||
if [[ ! -z "${RELEASE_PROJECT_CURRENT_VERSION}" ]]; then
|
||||
echo "already set up."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
nix run . -- \
|
||||
nix run ${{ github.action_path }} -- \
|
||||
declare \
|
||||
--state "${RELEASE_ACTION_STATEFILE}" \
|
||||
--release-yaml-filename "${{ inputs.filename }}" \
|
||||
--gitea-instance "${{ inputs.gitea_instance }}" \
|
||||
--release-repository-name "${{ inputs.repository }}" \
|
||||
--release-ref-name "${{ github.ref_name }}" \
|
||||
--release-run-number "${{ github.run_number }}" \
|
||||
--release-commit-sha "${{ github.sha }}" \
|
||||
--is-pre-release "${IS_PRE_RELEASE}"
|
||||
|
||||
nix run . -- \
|
||||
dump \
|
||||
--state "${RELEASE_ACTION_STATEFILE}" \
|
||||
--write-env-vars-to-filename "$GITHUB_ENV"
|
||||
|
||||
- name: declare release project
|
||||
if: inputs.version_descriptor != ''
|
||||
run: |
|
||||
if [[ "${{ github.ref_name }}" == "master" || "${{ github.ref_name }}" == "main" ]]; then
|
||||
IS_PRE_RELEASE="0"
|
||||
else
|
||||
IS_PRE_RELEASE="1"
|
||||
fi
|
||||
|
||||
nix run . -- \
|
||||
declare \
|
||||
--state "${RELEASE_ACTION_STATEFILE}" \
|
||||
--version-descriptor "${{ inputs.version_descriptor }}" \
|
||||
--gitea-instance "${{ inputs.gitea_instance }}" \
|
||||
--release-repository-name "${{ inputs.repository }}" \
|
||||
--release-ref-name "${{ github.ref_name }}" \
|
||||
--release-run-number "${{ github.run_number }}" \
|
||||
--release-commit-sha "${{ github.sha }}" \
|
||||
--is-pre-release "${IS_PRE_RELEASE}" \
|
||||
--write-env-vars-to-filename "$GITHUB_ENV"
|
||||
|
||||
if [[ ! -z "${{ inputs.artefact_type }}" ]]; then
|
||||
nix run . -- \
|
||||
nix run ${{ github.action_path }} -- \
|
||||
add-artefact \
|
||||
--state "${RELEASE_ACTION_STATEFILE}" \
|
||||
--artefact-type "${{ inputs.artefact_type }}" \
|
||||
@@ -163,13 +124,12 @@ runs:
|
||||
--artefact-name "${{ inputs.artefact_name }}" \
|
||||
--artefact-filename "${{ inputs.artefact_filename }}" \
|
||||
--artefact-package-name "${{ inputs.artefact_package_name }}" \
|
||||
--artefact-pattern "${{ inputs.artefact_pattern }}" \
|
||||
--artefact-directory "${{ inputs.artefact_directory }}" \
|
||||
--version-descriptor "${{ inputs.artefact_version_descriptor }}"
|
||||
fi
|
||||
|
||||
if [[ ! -z "${{ inputs.deployment_type }}" ]]; then
|
||||
nix run . -- \
|
||||
nix run ${{ github.action_path }} -- \
|
||||
add-deployment \
|
||||
--state "${RELEASE_ACTION_STATEFILE}" \
|
||||
--deployment-type "${{ inputs.deployment_type }}" \
|
||||
@@ -179,8 +139,3 @@ runs:
|
||||
--deployment-namespace "${{ inputs.deployment_namespace }}" \
|
||||
--deployment-repository "${{ inputs.deployment_repository }}"
|
||||
fi
|
||||
|
||||
nix run . -- \
|
||||
dump \
|
||||
--state "${RELEASE_ACTION_STATEFILE}" \
|
||||
--write-env-vars-to-filename "$GITHUB_ENV"
|
||||
|
||||
@@ -4,8 +4,25 @@ description: "dump current project description"
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: declare project if neccessary
|
||||
run: |
|
||||
if [[ ! -z "${RELEASE_PROJECT_CURRENT_VERSION}" ]]; then
|
||||
echo "already set up."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
nix run ${{ github.action_path }} -- \
|
||||
declare \
|
||||
--release-yaml-filename ".gitea/release.yaml" \
|
||||
--gitea-instance "https://gitea.puzzleyou.net" \
|
||||
--release-repository-name "${{ github.repository }}" \
|
||||
--release-ref-name "${{ github.ref_name }}" \
|
||||
--release-run-number "${{ github.run_number }}" \
|
||||
--release-commit-sha "${{ github.sha }}" \
|
||||
--write-env-vars-to-filename "$GITHUB_ENV"
|
||||
|
||||
- name: dump project description
|
||||
run: |
|
||||
nix run . -- \
|
||||
nix run ${{ github.action_path }} -- \
|
||||
dump \
|
||||
--state "${RELEASE_ACTION_STATEFILE}"
|
||||
|
||||
23
flake.lock
generated
23
flake.lock
generated
@@ -34,10 +34,31 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"pyproject-nix": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1764134915,
|
||||
"narHash": "sha256-xaKvtPx6YAnA3HQVp5LwyYG1MaN4LLehpQI8xEdBvBY=",
|
||||
"owner": "pyproject-nix",
|
||||
"repo": "pyproject.nix",
|
||||
"rev": "2c8df1383b32e5443c921f61224b198a2282a657",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "pyproject-nix",
|
||||
"repo": "pyproject.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
"nixpkgs": "nixpkgs",
|
||||
"pyproject-nix": "pyproject-nix"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
|
||||
47
flake.nix
47
flake.nix
@@ -4,50 +4,41 @@
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
pyproject-nix = {
|
||||
url = "github:pyproject-nix/pyproject.nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, ... }:
|
||||
outputs = { self, nixpkgs, flake-utils, pyproject-nix }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
|
||||
python = pkgs.python313.withPackages (ps: with ps; [
|
||||
isort
|
||||
flake8
|
||||
semver
|
||||
toml
|
||||
requests
|
||||
pyyaml
|
||||
]);
|
||||
|
||||
pythonPackage = pkgs.python3Packages.buildPythonPackage {
|
||||
name = "release-action";
|
||||
src = ./.;
|
||||
pythonProject = pyproject-nix.lib.project.loadPyproject {
|
||||
projectRoot = ./.;
|
||||
};
|
||||
|
||||
pythonInterpreter = pkgs.python313;
|
||||
in
|
||||
{
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = [
|
||||
pkgs.envsubst
|
||||
pkgs.just
|
||||
pkgs.gitea-actions-runner
|
||||
python
|
||||
(pythonInterpreter.withPackages
|
||||
(pythonProject.renderers.withPackages {
|
||||
python = pythonInterpreter;
|
||||
extraPackages = ps: with ps; [ flake8 isort ];
|
||||
}))
|
||||
];
|
||||
};
|
||||
|
||||
packages.default = pkgs.writers.writePython3Bin
|
||||
"release-action"
|
||||
{
|
||||
libraries = with pkgs.python3Packages; [
|
||||
semver # TODO move to setup.py?
|
||||
toml
|
||||
requests
|
||||
pythonPackage
|
||||
pyyaml
|
||||
];
|
||||
}
|
||||
(builtins.readFile ./src/main.py)
|
||||
;
|
||||
packages.default = pythonInterpreter.pkgs.buildPythonPackage (
|
||||
pythonProject.renderers.buildPythonPackage {
|
||||
python = pythonInterpreter;
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
18
justfile
18
justfile
@@ -24,4 +24,20 @@ test-workflows:
|
||||
--workflows ./.gitea/workflows/check.yaml \
|
||||
--job test-declare-default
|
||||
|
||||
# --image "europe-docker.pkg.dev/puzzle-and-play/docker/action-runner-job:latest" \
|
||||
act_runner exec \
|
||||
--image "-self-hosted" \
|
||||
--event pull_request \
|
||||
--workflows ./.gitea/workflows/check.yaml \
|
||||
--job test-is-not-yet-released
|
||||
|
||||
act_runner exec \
|
||||
--image "-self-hosted" \
|
||||
--event pull_request \
|
||||
--workflows ./.gitea/workflows/check.yaml \
|
||||
--job test-skip-release-if-already-released
|
||||
|
||||
act_runner exec \
|
||||
--image "-self-hosted" \
|
||||
--event pull_request \
|
||||
--workflows ./.gitea/workflows/check.yaml \
|
||||
--job test-sync-versions
|
||||
|
||||
16
pyproject.toml
Normal file
16
pyproject.toml
Normal file
@@ -0,0 +1,16 @@
|
||||
[project]
|
||||
name = "gitea-release-action"
|
||||
version = "0.0.1"
|
||||
description = "reusable action for release workflows"
|
||||
authors = [ ]
|
||||
requires-python = ">=3.13"
|
||||
dependencies = [
|
||||
"semver",
|
||||
"toml",
|
||||
"requests",
|
||||
"pyyaml",
|
||||
"packaging"
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
gitea-release-action = "main:main_cli"
|
||||
@@ -7,26 +7,82 @@ inputs:
|
||||
description: "do not change external state"
|
||||
default: false
|
||||
|
||||
configure_runner_environment:
|
||||
required: false
|
||||
default: true
|
||||
|
||||
build_run:
|
||||
required: false
|
||||
description: "commands to run before publishing artefacts"
|
||||
default: ""
|
||||
|
||||
sync_versions:
|
||||
required: false
|
||||
default: true
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: publish artefacts
|
||||
- if: inputs.configure_runner_environment == 'true'
|
||||
uses: https://gitea.puzzleyou.net/actions/configure-runner-environment@master
|
||||
|
||||
- name: declare project if neccessary
|
||||
run: |
|
||||
nix run . -- \
|
||||
if [[ ! -z "${RELEASE_PROJECT_CURRENT_VERSION}" ]]; then
|
||||
echo "already set up."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
nix run ${{ github.action_path }} -- \
|
||||
declare \
|
||||
--release-yaml-filename ".gitea/release.yaml" \
|
||||
--gitea-instance "https://gitea.puzzleyou.net" \
|
||||
--release-repository-name "${{ github.repository }}" \
|
||||
--release-ref-name "${{ github.ref_name }}" \
|
||||
--release-run-number "${{ github.run_number }}" \
|
||||
--release-commit-sha "${{ github.sha }}" \
|
||||
--write-env-vars-to-filename "$GITHUB_ENV"
|
||||
|
||||
- name: check if already released
|
||||
id: check_released
|
||||
run: |
|
||||
if [[ "$RELEASE_PROJECT_IS_RELEASED" == "1" ]] && [[ "$RELEASE_IS_PRERELEASE" == "0" ]]; then
|
||||
echo "is_released=1" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "is_released=0" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: sync versions
|
||||
if: ${{ steps.check_released.outputs.is_released == '0' && inputs.sync_versions == 'true' }}
|
||||
run: |
|
||||
nix run ${{ github.action_path }} -- \
|
||||
sync-versions \
|
||||
--state "${RELEASE_ACTION_STATEFILE}"
|
||||
|
||||
- name: run build commands
|
||||
if: ${{ steps.check_released.outputs.is_released == '0' && inputs.build_run != '' }}
|
||||
run: ${{ inputs.build_run }}
|
||||
|
||||
- name: publish artefacts
|
||||
if: ${{ steps.check_released.outputs.is_released == '0' }}
|
||||
run: |
|
||||
nix run ${{ github.action_path }} -- \
|
||||
publish-artefacts \
|
||||
--state "${RELEASE_ACTION_STATEFILE}" \
|
||||
--dry-run "${{ inputs.dry_run }}"
|
||||
|
||||
- name: update deployments
|
||||
if: ${{ steps.check_released.outputs.is_released == '0' }}
|
||||
run: |
|
||||
nix run . -- \
|
||||
nix run ${{ github.action_path }} -- \
|
||||
update-deployments \
|
||||
--state "${RELEASE_ACTION_STATEFILE}" \
|
||||
--dry-run "${{ inputs.dry_run }}"
|
||||
|
||||
- name: create release
|
||||
if: ${{ steps.check_released.outputs.is_released == '0' }}
|
||||
run: |
|
||||
nix run . -- \
|
||||
nix run ${{ github.action_path }} -- \
|
||||
create-release \
|
||||
--state "${RELEASE_ACTION_STATEFILE}" \
|
||||
--dry-run "${{ inputs.dry_run }}"
|
||||
|
||||
6
setup.py
6
setup.py
@@ -1,6 +0,0 @@
|
||||
from setuptools import setup
|
||||
|
||||
setup(
|
||||
name='release-action',
|
||||
version='0.0.1.dev0',
|
||||
)
|
||||
86
src/main.py
86
src/main.py
@@ -2,6 +2,8 @@ import pickle
|
||||
import re
|
||||
from argparse import ArgumentParser
|
||||
from dataclasses import replace
|
||||
from os import path
|
||||
from tempfile import gettempdir
|
||||
from typing import Optional
|
||||
|
||||
import yaml
|
||||
@@ -80,7 +82,7 @@ def dump_project_description(project_description: ProjectDescription):
|
||||
print(' release version name: %s' % release_info.version_str)
|
||||
|
||||
elif isinstance(generated, Wheel):
|
||||
print(' - wheel: %s' % generated.pattern)
|
||||
print(' - wheel: %s' % generated.filename)
|
||||
print(' repository: %s' % generated.repository)
|
||||
print(' release version name: %s' % release_info.version_str)
|
||||
|
||||
@@ -150,7 +152,6 @@ def make_artefact(type: str,
|
||||
name: str,
|
||||
filename: str,
|
||||
package_name: str,
|
||||
pattern: str,
|
||||
directory: str,
|
||||
version_descriptor) -> ArtefactDescription:
|
||||
|
||||
@@ -170,8 +171,8 @@ def make_artefact(type: str,
|
||||
**maybe_repository)
|
||||
|
||||
elif type == 'wheel':
|
||||
assert pattern is not None
|
||||
generated = Wheel(pattern=pattern, **maybe_repository)
|
||||
assert filename is not None
|
||||
generated = Wheel(filename=filename, **maybe_repository)
|
||||
|
||||
elif type == 'sdist':
|
||||
assert filename is not None
|
||||
@@ -231,15 +232,29 @@ def make_deployment(type: str,
|
||||
return DeploymentDescription(deployment=deployment, **maybe_condition)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
def sync_versions(project_description: ProjectDescription):
|
||||
planned_version = project_description.planned_version
|
||||
|
||||
def sync(descriptor_filename: str):
|
||||
v = versioning.use_any(descriptor_filename)
|
||||
v.version = planned_version
|
||||
v.store()
|
||||
|
||||
sync(project_description.version_descriptor)
|
||||
|
||||
for artefact in project_description.artefacts:
|
||||
if artefact.version_descriptor is not None:
|
||||
sync(artefact.version_descriptor)
|
||||
|
||||
|
||||
def main_cli():
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument('action', choices=[
|
||||
# TODO missing: adjust version (development)
|
||||
# TODO missing: check if release already exists
|
||||
'declare',
|
||||
'check',
|
||||
'add-artefact',
|
||||
'add-deployment',
|
||||
'sync-versions',
|
||||
'publish-artefacts',
|
||||
'update-deployments',
|
||||
'create-release',
|
||||
@@ -262,7 +277,7 @@ if __name__ == '__main__':
|
||||
else:
|
||||
raise Exception('flag can be "0" or "1". got: %s' % val)
|
||||
|
||||
parser.add_argument('--state', required=True)
|
||||
parser.add_argument('--state', type=nullable_string)
|
||||
parser.add_argument('--version-descriptor', type=nullable_string)
|
||||
parser.add_argument('--release-yaml-filename', type=nullable_string)
|
||||
parser.add_argument('--dry-run', type=true_or_false)
|
||||
@@ -281,7 +296,6 @@ if __name__ == '__main__':
|
||||
parser.add_argument('--artefact-name', type=nullable_string)
|
||||
parser.add_argument('--artefact-package-name', type=nullable_string)
|
||||
parser.add_argument('--artefact-filename', type=nullable_string)
|
||||
parser.add_argument('--artefact-pattern', type=nullable_string)
|
||||
parser.add_argument('--artefact-directory', type=nullable_string)
|
||||
|
||||
parser.add_argument('--deployment-type',
|
||||
@@ -296,6 +310,8 @@ if __name__ == '__main__':
|
||||
parser.add_argument('--write-env-vars-to-filename')
|
||||
|
||||
args = parser.parse_args()
|
||||
state_file = (args.state
|
||||
or str(path.join(gettempdir(), 'release_project_state')))
|
||||
|
||||
def clean_repository_name(name: str) -> str:
|
||||
if name.startswith('//'):
|
||||
@@ -304,13 +320,22 @@ if __name__ == '__main__':
|
||||
return name
|
||||
|
||||
if args.action == 'declare':
|
||||
if args.release_yaml_filename is None:
|
||||
project_description = make_project_description(
|
||||
args.version_descriptor)
|
||||
else:
|
||||
if args.version_descriptor is None:
|
||||
with open(args.release_yaml_filename, 'r') as f:
|
||||
project_description = parse_project_description(
|
||||
yaml.safe_load(f))
|
||||
else:
|
||||
project_description = make_project_description(
|
||||
args.version_descriptor)
|
||||
|
||||
if args.is_pre_release is None:
|
||||
assert args.release_ref_name is not None
|
||||
|
||||
is_pre_release = not any(
|
||||
map(lambda rn: rn in args.release_ref_name,
|
||||
['master', 'main']))
|
||||
else:
|
||||
is_pre_release = args.is_pre_release
|
||||
|
||||
project_description = replace(
|
||||
project_description,
|
||||
@@ -320,19 +345,18 @@ if __name__ == '__main__':
|
||||
args.release_ref_name,
|
||||
args.release_run_number,
|
||||
args.release_commit_sha,
|
||||
args.is_pre_release))
|
||||
is_pre_release))
|
||||
|
||||
save_project_description(args.state, project_description)
|
||||
save_project_description(state_file, project_description)
|
||||
|
||||
elif args.action == 'add-artefact':
|
||||
project_description = load_project_description(args.state)
|
||||
project_description = load_project_description(state_file)
|
||||
|
||||
artefact = make_artefact(args.artefact_type,
|
||||
args.artefact_repository,
|
||||
args.artefact_name,
|
||||
args.artefact_filename,
|
||||
args.artefact_package_name,
|
||||
args.artefact_pattern,
|
||||
args.artefact_directory,
|
||||
args.version_descriptor)
|
||||
|
||||
@@ -340,10 +364,10 @@ if __name__ == '__main__':
|
||||
project_description,
|
||||
artefacts=project_description.artefacts + [artefact])
|
||||
|
||||
save_project_description(args.state, project_description)
|
||||
save_project_description(state_file, project_description)
|
||||
|
||||
elif args.action == 'add-deployment':
|
||||
project_description = load_project_description(args.state)
|
||||
project_description = load_project_description(state_file)
|
||||
|
||||
deployment = make_deployment(args.deployment_type,
|
||||
args.deployment_release_name,
|
||||
@@ -356,38 +380,46 @@ if __name__ == '__main__':
|
||||
project_description,
|
||||
deployments=project_description.deployments + [deployment])
|
||||
|
||||
save_project_description(args.state, project_description)
|
||||
save_project_description(state_file, project_description)
|
||||
|
||||
elif args.action == 'sync-versions':
|
||||
project_description = load_project_description(state_file)
|
||||
sync_versions(project_description)
|
||||
|
||||
elif args.action == 'publish-artefacts':
|
||||
project_description = load_project_description(args.state)
|
||||
project_description = load_project_description(state_file)
|
||||
publish_artefacts(project_description, args.dry_run)
|
||||
|
||||
elif args.action == 'update-deployments':
|
||||
project_description = load_project_description(args.state)
|
||||
project_description = load_project_description(state_file)
|
||||
update_deployments(project_description, args.dry_run)
|
||||
|
||||
elif args.action == 'create-release':
|
||||
project_description = load_project_description(args.state)
|
||||
project_description = load_project_description(state_file)
|
||||
create_release(project_description, args.dry_run)
|
||||
|
||||
elif args.action == 'dump':
|
||||
project_description = load_project_description(args.state)
|
||||
project_description = load_project_description(state_file)
|
||||
dump_project_description(project_description)
|
||||
|
||||
elif args.action == 'check':
|
||||
project_description = load_project_description(args.state)
|
||||
project_description = load_project_description(state_file)
|
||||
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
|
||||
assert project_description is not None
|
||||
assert state_file is not None
|
||||
|
||||
env_var_filename = args.write_env_vars_to_filename
|
||||
if env_var_filename is not None:
|
||||
env_vars = project_description.environment_variables
|
||||
env_vars = {
|
||||
'RELEASE_ACTION_STATEFILE': state_file,
|
||||
**project_description.environment_variables
|
||||
}
|
||||
|
||||
assert not any(map(lambda v: '"' in v, env_vars.values()))
|
||||
|
||||
with open(env_var_filename, 'a') as f:
|
||||
f.write(
|
||||
'\n'.join(map(lambda it: '%s="%s"' % it, env_vars.items())))
|
||||
'\n'.join(map(lambda it: '%s=%s' % it, env_vars.items())))
|
||||
|
||||
12
src/release/common.py
Normal file
12
src/release/common.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from packaging.version import parse as parse_version
|
||||
from semver import Version
|
||||
|
||||
|
||||
def python_version_str(version: Version) -> str:
|
||||
return ('%d.%d.%d' % (version.major, version.minor, version.patch)) \
|
||||
+ ('' if version.prerelease is None else '.%s' % version.prerelease)
|
||||
|
||||
|
||||
def python_parse_version(txt: str) -> Version:
|
||||
version = parse_version(txt)
|
||||
return Version(*version.release, version.pre)
|
||||
@@ -6,6 +6,7 @@ from itertools import chain
|
||||
from typing import Optional, Union
|
||||
|
||||
from release import toolkit, versioning
|
||||
from release.common import python_version_str
|
||||
from release.context import ReleaseContext
|
||||
from release.versioning import Version
|
||||
|
||||
@@ -20,11 +21,6 @@ def _normalize_env_var_fragment(txt: str) -> str:
|
||||
return txt.upper().replace('-', '_').replace('.', '_')
|
||||
|
||||
|
||||
def _python_version_str(version: Version) -> str:
|
||||
return ('%d.%d.%d' % (version.major, version.minor, version.patch)) \
|
||||
+ ('' if version.prerelease is None else '.%s' % version.prerelease)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class OciImageReleaseInfo:
|
||||
image_name: str
|
||||
@@ -101,14 +97,14 @@ class Tarball:
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class WheelReleaseInfo:
|
||||
pattern: str
|
||||
filename: str
|
||||
repository: str
|
||||
version_str: str
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Wheel:
|
||||
pattern: str
|
||||
filename: str
|
||||
repository: str = DEFAULT_PYPI_REPOSITORY_NAME
|
||||
|
||||
def make_environment_variables(self, context, version):
|
||||
@@ -116,9 +112,9 @@ class Wheel:
|
||||
|
||||
def make_release_info(self, context: ReleaseContext, version: Version):
|
||||
return WheelReleaseInfo(
|
||||
pattern=self.pattern,
|
||||
filename=self.filename,
|
||||
repository=self.repository,
|
||||
version_str=_python_version_str(version))
|
||||
version_str=python_version_str(version))
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -140,7 +136,7 @@ class Sdist:
|
||||
return SdistReleaseInfo(
|
||||
filename=self.filename,
|
||||
repository=self.repository,
|
||||
version_str=_python_version_str(version))
|
||||
version_str=python_version_str(version))
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -266,7 +262,7 @@ class ProjectDescription:
|
||||
if self.gitea_tool is None:
|
||||
return None
|
||||
|
||||
return self.gitea_tool.is_released(self.planned_version)
|
||||
return self.gitea_tool.is_released(self.project_version)
|
||||
|
||||
@cached_property
|
||||
def gitea_tool(self):
|
||||
@@ -306,6 +302,8 @@ class ProjectDescription:
|
||||
str(self.project_version),
|
||||
'RELEASE_PROJECT_PLANNED_VERSION':
|
||||
str(self.planned_version),
|
||||
'RELEASE_PROJECT_IS_RELEASED':
|
||||
'1' if self.is_released else '0',
|
||||
}]
|
||||
))
|
||||
|
||||
@@ -329,8 +327,8 @@ def parse_project_description(obj):
|
||||
**optional(tar, 'repository'))
|
||||
|
||||
def parse_wheel(whl):
|
||||
assert 'pattern' in whl
|
||||
return Wheel(pattern=whl['pattern'],
|
||||
assert 'filename' in whl
|
||||
return Wheel(filename=whl['filename'],
|
||||
**optional(whl, 'repository'))
|
||||
|
||||
def parse_sdist(sdist):
|
||||
|
||||
@@ -9,6 +9,8 @@ from release.project import (DeploymentCondition, HelmRelease, HelmReleaseInfo,
|
||||
SdistReleaseInfo, Tarball, TarballReleaseInfo,
|
||||
Wheel, WheelReleaseInfo)
|
||||
|
||||
DEFAULT_PACKAGE_OWNER = 'puzzleYOU'
|
||||
|
||||
|
||||
class Cli:
|
||||
def __init__(self, dry_run: bool):
|
||||
@@ -63,11 +65,12 @@ def publish_tarball(info: TarballReleaseInfo, cli: Cli):
|
||||
cli('curl',
|
||||
'--netrc',
|
||||
'--fail-with-body',
|
||||
'--upload-file %s' % info.filename,
|
||||
'--upload-file', info.filename,
|
||||
'-i',
|
||||
'-X', 'PUT',
|
||||
'%s/api/packages/puzzleYOU/generic/%s/%s/%s' % ( # TODO owner
|
||||
'%s/api/packages/%s/generic/%s/%s/%s' % (
|
||||
info.repository,
|
||||
DEFAULT_PACKAGE_OWNER,
|
||||
info.package_name,
|
||||
info.version_str,
|
||||
path.basename(info.filename)))
|
||||
@@ -81,7 +84,7 @@ def publish_wheel(info: WheelReleaseInfo, cli: Cli):
|
||||
'upload',
|
||||
'--verbose',
|
||||
'--repository', info.repository,
|
||||
info.pattern)
|
||||
info.filename)
|
||||
print()
|
||||
|
||||
|
||||
@@ -147,19 +150,19 @@ def update_helm_release(info: HelmReleaseInfo, cli: Cli):
|
||||
'--version', chart_version,
|
||||
'-d', td)
|
||||
|
||||
chart_filename = '%s/%s-%s.tgz' % (td, chart_name, chart_version)
|
||||
chart_filename = '%s/%s-%s.tgz' % (td, chart_name, chart_version)
|
||||
|
||||
value_overrides = ','.join(
|
||||
map(lambda t: '%s=%s' % (t, info.image_tag), info.image_paths))
|
||||
value_overrides = ','.join(
|
||||
map(lambda t: '%s=%s' % (t, info.image_tag), info.image_paths))
|
||||
|
||||
cli('helm',
|
||||
'upgrade', info.release_name,
|
||||
chart_filename,
|
||||
'--version', chart_version,
|
||||
'--namespace', info.namespace,
|
||||
'--reuse-values',
|
||||
'--set', value_overrides,
|
||||
'--timeout', info.timeout)
|
||||
cli('helm',
|
||||
'upgrade', info.release_name,
|
||||
chart_filename,
|
||||
'--version', chart_version,
|
||||
'--namespace', info.namespace,
|
||||
'--reuse-values',
|
||||
'--set', value_overrides,
|
||||
'--timeout', info.timeout)
|
||||
|
||||
|
||||
def update_deployments(project: ProjectDescription, dry_run: bool = False):
|
||||
|
||||
@@ -19,10 +19,10 @@ artefacts:
|
||||
repository: balls
|
||||
|
||||
- type: wheel
|
||||
pattern: './scratch/wheels/*.whl'
|
||||
filename: './scratch/wheels/*.whl'
|
||||
|
||||
- type: wheel
|
||||
pattern: './scratch/wheels/*.whl'
|
||||
filename: './scratch/wheels/*.whl'
|
||||
repository: other
|
||||
|
||||
- type: sdist
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from os import path
|
||||
from unittest import TestCase
|
||||
from unittest.mock import patch
|
||||
|
||||
import yaml
|
||||
from semver import Version
|
||||
@@ -14,6 +15,14 @@ from release.project import (ArtefactDescription, DeploymentCondition,
|
||||
WheelReleaseInfo, parse_project_description)
|
||||
|
||||
|
||||
class MockGiteaTool:
|
||||
def __init__(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
def is_released(self, version):
|
||||
return False
|
||||
|
||||
|
||||
class TestProjectDescription(TestCase):
|
||||
def test_can_describe_projects(self):
|
||||
# resi-lib
|
||||
@@ -21,7 +30,7 @@ class TestProjectDescription(TestCase):
|
||||
version_descriptor='src/python/Cargo.toml',
|
||||
artefacts=[
|
||||
ArtefactDescription(
|
||||
generated=Wheel(pattern='./scratch/wheels/*.whl'))
|
||||
generated=Wheel(filename='./scratch/wheels/*.whl'))
|
||||
])
|
||||
|
||||
# productdesignerd
|
||||
@@ -46,7 +55,7 @@ class TestProjectDescription(TestCase):
|
||||
ArtefactDescription(
|
||||
generated=OciImage(name='masa-images')),
|
||||
ArtefactDescription(
|
||||
generated=Wheel(pattern='./scratch/wheels/*.whl'))
|
||||
generated=Wheel(filename='./scratch/wheels/*.whl'))
|
||||
],
|
||||
deployments=[
|
||||
DeploymentDescription(
|
||||
@@ -125,7 +134,7 @@ class TestProjectDescription(TestCase):
|
||||
artefacts=[
|
||||
ArtefactDescription(
|
||||
version_descriptor='src/python/pyproject.toml',
|
||||
generated=Wheel(pattern='./scratch/wheels/*.whl')),
|
||||
generated=Wheel(filename='./scratch/wheels/*.whl')),
|
||||
ArtefactDescription(generated=OciImage(name='prngl')),
|
||||
],
|
||||
deployments=[
|
||||
@@ -136,6 +145,7 @@ class TestProjectDescription(TestCase):
|
||||
namespace='prngl-testing'))
|
||||
])
|
||||
|
||||
@patch('release.project.toolkit.Gitea', MockGiteaTool)
|
||||
def test_environment_variables(self):
|
||||
# motacilla
|
||||
desc = ProjectDescription(
|
||||
@@ -184,6 +194,7 @@ class TestProjectDescription(TestCase):
|
||||
'RELEASE_IMAGE_LOCAL_NAME_MOTACILLA_CDN':
|
||||
'motacilla-cdn:0AB123',
|
||||
'RELEASE_IS_PRERELEASE': '1',
|
||||
'RELEASE_PROJECT_IS_RELEASED': '0',
|
||||
'RELEASE_PROJECT_CURRENT_VERSION': '2.10.4',
|
||||
'RELEASE_PROJECT_PLANNED_VERSION': '2.10.4-dev42'
|
||||
}
|
||||
@@ -200,9 +211,9 @@ class TestProjectDescription(TestCase):
|
||||
tarball.make_release_info(None, Version(1, 2, 3, 'dev4')))
|
||||
|
||||
def test_wheel_release_info(self):
|
||||
wheel = Wheel(pattern='dist/wheels/*')
|
||||
wheel = Wheel(filename='dist/wheels/*')
|
||||
self.assertEqual(
|
||||
WheelReleaseInfo(pattern='dist/wheels/*',
|
||||
WheelReleaseInfo(filename='dist/wheels/*',
|
||||
repository='gitea',
|
||||
version_str='1.2.3.dev4'),
|
||||
wheel.make_release_info(None, Version(1, 2, 3, 'dev4')))
|
||||
@@ -293,11 +304,12 @@ class TestProjectDescription(TestCase):
|
||||
img.make_release_info(release_context, release_version))
|
||||
|
||||
def test_project_release_info(self):
|
||||
project_0 = ProjectDescription(version_descriptor='version.txt')
|
||||
project_0 = ProjectDescription(
|
||||
version_descriptor='test-assets/version.txt')
|
||||
self.assertIsNone(project_0.release_info)
|
||||
|
||||
project_pre = ProjectDescription(
|
||||
version_descriptor='version.txt',
|
||||
version_descriptor='test-assets/version.txt',
|
||||
context=ReleaseContext(
|
||||
repository_name='resi',
|
||||
ref_name='testing',
|
||||
@@ -308,16 +320,16 @@ class TestProjectDescription(TestCase):
|
||||
|
||||
self.assertEqual(
|
||||
ProjectReleaseInfo(
|
||||
gitea_release_title='Version 0.0.1-dev42',
|
||||
gitea_release_title='Version 1.33.7-dev42',
|
||||
gitea_release_description='',
|
||||
gitea_is_prerelease=True,
|
||||
gitea_git_commitish='PROBABLY_BROKEN',
|
||||
git_tags=['v0.0.1-dev42', 'development'],
|
||||
git_tags=['v1.33.7-dev42', 'development'],
|
||||
),
|
||||
project_pre.release_info)
|
||||
|
||||
project = ProjectDescription(
|
||||
version_descriptor='version.txt',
|
||||
version_descriptor='test-assets/version.txt',
|
||||
context=ReleaseContext(
|
||||
repository_name='resi',
|
||||
ref_name='master',
|
||||
@@ -328,11 +340,11 @@ class TestProjectDescription(TestCase):
|
||||
|
||||
self.assertEqual(
|
||||
ProjectReleaseInfo(
|
||||
gitea_release_title='Version 0.0.1',
|
||||
gitea_release_title='Version 1.33.7',
|
||||
gitea_release_description='',
|
||||
gitea_is_prerelease=False,
|
||||
gitea_git_commitish='PROBABLY_BROKEN',
|
||||
git_tags=['v0.0.1', 'v0.0', 'v0', 'latest'],
|
||||
git_tags=['v1.33.7', 'v1.33', 'v1', 'latest'],
|
||||
),
|
||||
project.release_info)
|
||||
|
||||
@@ -354,9 +366,9 @@ class TestProjectDescription(TestCase):
|
||||
repository='balls')),
|
||||
|
||||
ArtefactDescription(generated=Wheel(
|
||||
pattern='./scratch/wheels/*.whl')),
|
||||
filename='./scratch/wheels/*.whl')),
|
||||
ArtefactDescription(generated=Wheel(
|
||||
pattern='./scratch/wheels/*.whl', repository='other')),
|
||||
filename='./scratch/wheels/*.whl', repository='other')),
|
||||
|
||||
ArtefactDescription(generated=Sdist(
|
||||
filename='./dist/papyru-0.0.1.tar.gz')),
|
||||
|
||||
@@ -18,12 +18,12 @@ def _test_can_read_version(test, filename, expected):
|
||||
|
||||
def _test_can_write_version(test, filename):
|
||||
v = use_any(_asset_path(filename))
|
||||
v.version = Version(1, 33, 7)
|
||||
v.version = Version(1, 33, 7, 42)
|
||||
|
||||
with NamedTemporaryFile() as tf:
|
||||
v.store(tf.name)
|
||||
v2 = use_any(tf.name)
|
||||
test.assertEqual(v2.version, Version(1, 33, 7))
|
||||
test.assertEqual(v2.version, Version(1, 33, 7, 42))
|
||||
|
||||
|
||||
class TestSetupPy(TestCase):
|
||||
|
||||
@@ -6,6 +6,8 @@ from logging import getLogger
|
||||
import toml
|
||||
from semver import Version
|
||||
|
||||
from release.common import python_parse_version, python_version_str
|
||||
|
||||
logger = getLogger(__name__)
|
||||
RE_SETUP_PY = re.compile(r'version\s?=\s?[\'"](.*)[\'"]')
|
||||
|
||||
@@ -24,12 +26,13 @@ class SetupPy:
|
||||
|
||||
self.filename = filename
|
||||
self.content = content
|
||||
self.version = Version.parse(version_string.group(1))
|
||||
self.version = python_parse_version(version_string.group(1))
|
||||
|
||||
def store(self, destination=None):
|
||||
destination = destination or self.filename
|
||||
edited = RE_SETUP_PY.sub(
|
||||
'version=\'%s\'' % self.version, self.content)
|
||||
'version=\'%s\'' % python_version_str(self.version),
|
||||
self.content)
|
||||
|
||||
with open(destination, 'w') as f:
|
||||
f.write(edited)
|
||||
@@ -44,6 +47,7 @@ class Structured:
|
||||
for part in item_path:
|
||||
cur = cur[part]
|
||||
|
||||
self.filename = filename
|
||||
self.format = format
|
||||
self.item_path = item_path
|
||||
self.content = obj
|
||||
|
||||
30
sync-versions/action.yaml
Normal file
30
sync-versions/action.yaml
Normal file
@@ -0,0 +1,30 @@
|
||||
name: "sync version descriptors"
|
||||
description: "update all version descriptors to the planned version."
|
||||
|
||||
inputs: {}
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: declare project if neccessary
|
||||
run: |
|
||||
if [[ ! -z "${RELEASE_PROJECT_CURRENT_VERSION}" ]]; then
|
||||
echo "already set up."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
nix run ${{ github.action_path }} -- \
|
||||
declare \
|
||||
--release-yaml-filename ".gitea/release.yaml" \
|
||||
--gitea-instance "https://gitea.puzzleyou.net" \
|
||||
--release-repository-name "${{ github.repository }}" \
|
||||
--release-ref-name "${{ github.ref_name }}" \
|
||||
--release-run-number "${{ github.run_number }}" \
|
||||
--release-commit-sha "${{ github.sha }}" \
|
||||
--write-env-vars-to-filename "$GITHUB_ENV"
|
||||
|
||||
- name: sync versions
|
||||
run: |
|
||||
nix run ${{ github.action_path }} -- \
|
||||
sync-versions \
|
||||
--state "${RELEASE_ACTION_STATEFILE}"
|
||||
@@ -1 +0,0 @@
|
||||
0.0.1
|
||||
Reference in New Issue
Block a user