Compare commits
1 Commits
v0.0.1-dev
...
v0.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
| bf30b4defe |
@@ -1 +1 @@
|
|||||||
version_descriptor: setup.py
|
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
|
||||||
@@ -67,6 +67,26 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
configure_runner_environment: false
|
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:
|
test-declare-with-release-yaml:
|
||||||
runs-on: action-runner
|
runs-on: action-runner
|
||||||
steps:
|
steps:
|
||||||
@@ -80,6 +100,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
dry_run: true
|
dry_run: true
|
||||||
configure_runner_environment: false
|
configure_runner_environment: false
|
||||||
|
sync_versions: false
|
||||||
|
|
||||||
- run: set -u; echo "$RELEASE_PROJECT_CURRENT_VERSION"
|
- run: set -u; echo "$RELEASE_PROJECT_CURRENT_VERSION"
|
||||||
|
|
||||||
@@ -114,7 +135,7 @@ jobs:
|
|||||||
- uses: ./add-artefact
|
- uses: ./add-artefact
|
||||||
with:
|
with:
|
||||||
type: wheel
|
type: wheel
|
||||||
pattern: "test-assets/wheels/*.whl"
|
filename: "test-assets/wheels/*.whl"
|
||||||
|
|
||||||
- uses: ./add-artefact
|
- uses: ./add-artefact
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ inputs:
|
|||||||
|
|
||||||
filename:
|
filename:
|
||||||
required: false
|
required: false
|
||||||
description: "required for tarball, sdist"
|
description: "required for tarball, sdist, wheel"
|
||||||
default: ""
|
default: ""
|
||||||
|
|
||||||
package_name:
|
package_name:
|
||||||
@@ -26,11 +26,6 @@ inputs:
|
|||||||
description: "required for tarball"
|
description: "required for tarball"
|
||||||
default: ""
|
default: ""
|
||||||
|
|
||||||
pattern:
|
|
||||||
required: false
|
|
||||||
description: "required for wheel"
|
|
||||||
default: ""
|
|
||||||
|
|
||||||
directory:
|
directory:
|
||||||
required: false
|
required: false
|
||||||
description: "required for npm"
|
description: "required for npm"
|
||||||
@@ -54,7 +49,6 @@ runs:
|
|||||||
--artefact-name "${{ inputs.name }}" \
|
--artefact-name "${{ inputs.name }}" \
|
||||||
--artefact-filename "${{ inputs.filename }}" \
|
--artefact-filename "${{ inputs.filename }}" \
|
||||||
--artefact-package-name "${{ inputs.package_name }}" \
|
--artefact-package-name "${{ inputs.package_name }}" \
|
||||||
--artefact-pattern "${{ inputs.pattern }}" \
|
|
||||||
--artefact-directory "${{ inputs.directory }}" \
|
--artefact-directory "${{ inputs.directory }}" \
|
||||||
--version-descriptor "${{ inputs.version_descriptor }}" \
|
--version-descriptor "${{ inputs.version_descriptor }}" \
|
||||||
--write-env-vars-to-filename "$GITHUB_ENV"
|
--write-env-vars-to-filename "$GITHUB_ENV"
|
||||||
|
|||||||
@@ -33,15 +33,11 @@ runs:
|
|||||||
run: |
|
run: |
|
||||||
set +e
|
set +e
|
||||||
|
|
||||||
nix run ${{ github.action_path }} -- \
|
if [[ "$RELEASE_PROJECT_IS_RELEASED" = "1" ]]; then
|
||||||
dump \
|
|
||||||
--state "${RELEASE_ACTION_STATEFILE}" \
|
|
||||||
| grep "is already released: True"
|
|
||||||
IS_RELEASED_EXIT_CODE=$?
|
|
||||||
|
|
||||||
if [[ "$IS_RELEASED_EXIT_CODE" -eq 0 ]]; then
|
|
||||||
VERSION="$RELEASE_PROJECT_CURRENT_VERSION"
|
VERSION="$RELEASE_PROJECT_CURRENT_VERSION"
|
||||||
echo "Project is already released with version ${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
|
exit -1
|
||||||
else
|
else
|
||||||
echo "Project is not yet released."
|
echo "Project is not yet released."
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ inputs:
|
|||||||
|
|
||||||
artefact_filename:
|
artefact_filename:
|
||||||
required: false
|
required: false
|
||||||
description: "required for tarball, sdist"
|
description: "required for tarball, sdist, wheel"
|
||||||
default: ""
|
default: ""
|
||||||
|
|
||||||
artefact_package_name:
|
artefact_package_name:
|
||||||
@@ -49,11 +49,6 @@ inputs:
|
|||||||
description: "required for tarball"
|
description: "required for tarball"
|
||||||
default: ""
|
default: ""
|
||||||
|
|
||||||
artefact_pattern:
|
|
||||||
required: false
|
|
||||||
description: "required for wheel"
|
|
||||||
default: ""
|
|
||||||
|
|
||||||
artefact_directory:
|
artefact_directory:
|
||||||
required: false
|
required: false
|
||||||
description: "required for npm"
|
description: "required for npm"
|
||||||
@@ -104,6 +99,11 @@ runs:
|
|||||||
|
|
||||||
- name: declare release project
|
- name: declare release project
|
||||||
run: |
|
run: |
|
||||||
|
if [[ ! -z "${RELEASE_PROJECT_CURRENT_VERSION}" ]]; then
|
||||||
|
echo "already set up."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
nix run ${{ github.action_path }} -- \
|
nix run ${{ github.action_path }} -- \
|
||||||
declare \
|
declare \
|
||||||
--release-yaml-filename "${{ inputs.filename }}" \
|
--release-yaml-filename "${{ inputs.filename }}" \
|
||||||
@@ -124,7 +124,6 @@ runs:
|
|||||||
--artefact-name "${{ inputs.artefact_name }}" \
|
--artefact-name "${{ inputs.artefact_name }}" \
|
||||||
--artefact-filename "${{ inputs.artefact_filename }}" \
|
--artefact-filename "${{ inputs.artefact_filename }}" \
|
||||||
--artefact-package-name "${{ inputs.artefact_package_name }}" \
|
--artefact-package-name "${{ inputs.artefact_package_name }}" \
|
||||||
--artefact-pattern "${{ inputs.artefact_pattern }}" \
|
|
||||||
--artefact-directory "${{ inputs.artefact_directory }}" \
|
--artefact-directory "${{ inputs.artefact_directory }}" \
|
||||||
--version-descriptor "${{ inputs.artefact_version_descriptor }}"
|
--version-descriptor "${{ inputs.artefact_version_descriptor }}"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -4,6 +4,23 @@ description: "dump current project description"
|
|||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
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
|
- name: dump project description
|
||||||
run: |
|
run: |
|
||||||
nix run ${{ github.action_path }} -- \
|
nix run ${{ github.action_path }} -- \
|
||||||
|
|||||||
23
flake.lock
generated
23
flake.lock
generated
@@ -34,10 +34,31 @@
|
|||||||
"type": "github"
|
"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": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs",
|
||||||
|
"pyproject-nix": "pyproject-nix"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"systems": {
|
"systems": {
|
||||||
|
|||||||
49
flake.nix
49
flake.nix
@@ -4,52 +4,41 @@
|
|||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
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:
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs { inherit system; };
|
pkgs = import nixpkgs { inherit system; };
|
||||||
|
|
||||||
python = pkgs.python313.withPackages (ps: with ps; [
|
pythonProject = pyproject-nix.lib.project.loadPyproject {
|
||||||
isort
|
projectRoot = ./.;
|
||||||
flake8
|
|
||||||
semver
|
|
||||||
toml
|
|
||||||
requests
|
|
||||||
pyyaml
|
|
||||||
packaging
|
|
||||||
]);
|
|
||||||
|
|
||||||
pythonPackage = pkgs.python3Packages.buildPythonPackage {
|
|
||||||
name = "release-action";
|
|
||||||
src = ./.;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pythonInterpreter = pkgs.python313;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
pkgs.envsubst
|
|
||||||
pkgs.just
|
pkgs.just
|
||||||
pkgs.gitea-actions-runner
|
pkgs.gitea-actions-runner
|
||||||
python
|
(pythonInterpreter.withPackages
|
||||||
|
(pythonProject.renderers.withPackages {
|
||||||
|
python = pythonInterpreter;
|
||||||
|
extraPackages = ps: with ps; [ flake8 isort ];
|
||||||
|
}))
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
packages.default = pkgs.writers.writePython3Bin
|
packages.default = pythonInterpreter.pkgs.buildPythonPackage (
|
||||||
"release-action"
|
pythonProject.renderers.buildPythonPackage {
|
||||||
{
|
python = pythonInterpreter;
|
||||||
libraries = with pkgs.python3Packages; [
|
});
|
||||||
semver # TODO move to setup.py?
|
|
||||||
toml
|
|
||||||
requests
|
|
||||||
pythonPackage
|
|
||||||
pyyaml
|
|
||||||
packaging
|
|
||||||
];
|
|
||||||
}
|
|
||||||
(builtins.readFile ./src/main.py)
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
9
justfile
9
justfile
@@ -34,7 +34,10 @@ test-workflows:
|
|||||||
--image "-self-hosted" \
|
--image "-self-hosted" \
|
||||||
--event pull_request \
|
--event pull_request \
|
||||||
--workflows ./.gitea/workflows/check.yaml \
|
--workflows ./.gitea/workflows/check.yaml \
|
||||||
--job test-sync-versions
|
--job test-skip-release-if-already-released
|
||||||
|
|
||||||
# TODO
|
act_runner exec \
|
||||||
# --image "europe-docker.pkg.dev/puzzle-and-play/docker/action-runner-job:latest" \
|
--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"
|
||||||
@@ -18,7 +18,7 @@ inputs:
|
|||||||
|
|
||||||
sync_versions:
|
sync_versions:
|
||||||
required: false
|
required: false
|
||||||
default: false
|
default: true
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
@@ -43,18 +43,28 @@ runs:
|
|||||||
--release-commit-sha "${{ github.sha }}" \
|
--release-commit-sha "${{ github.sha }}" \
|
||||||
--write-env-vars-to-filename "$GITHUB_ENV"
|
--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
|
- name: sync versions
|
||||||
if: inputs.sync_versions == 'true'
|
if: ${{ steps.check_released.outputs.is_released == '0' && inputs.sync_versions == 'true' }}
|
||||||
run: |
|
run: |
|
||||||
nix run ${{ github.action_path }} -- \
|
nix run ${{ github.action_path }} -- \
|
||||||
sync-versions \
|
sync-versions \
|
||||||
--state "${RELEASE_ACTION_STATEFILE}"
|
--state "${RELEASE_ACTION_STATEFILE}"
|
||||||
|
|
||||||
- name: run build commands
|
- name: run build commands
|
||||||
if: inputs.build_run != ''
|
if: ${{ steps.check_released.outputs.is_released == '0' && inputs.build_run != '' }}
|
||||||
run: ${{ inputs.build_run }}
|
run: ${{ inputs.build_run }}
|
||||||
|
|
||||||
- name: publish artefacts
|
- name: publish artefacts
|
||||||
|
if: ${{ steps.check_released.outputs.is_released == '0' }}
|
||||||
run: |
|
run: |
|
||||||
nix run ${{ github.action_path }} -- \
|
nix run ${{ github.action_path }} -- \
|
||||||
publish-artefacts \
|
publish-artefacts \
|
||||||
@@ -62,6 +72,7 @@ runs:
|
|||||||
--dry-run "${{ inputs.dry_run }}"
|
--dry-run "${{ inputs.dry_run }}"
|
||||||
|
|
||||||
- name: update deployments
|
- name: update deployments
|
||||||
|
if: ${{ steps.check_released.outputs.is_released == '0' }}
|
||||||
run: |
|
run: |
|
||||||
nix run ${{ github.action_path }} -- \
|
nix run ${{ github.action_path }} -- \
|
||||||
update-deployments \
|
update-deployments \
|
||||||
@@ -69,6 +80,7 @@ runs:
|
|||||||
--dry-run "${{ inputs.dry_run }}"
|
--dry-run "${{ inputs.dry_run }}"
|
||||||
|
|
||||||
- name: create release
|
- name: create release
|
||||||
|
if: ${{ steps.check_released.outputs.is_released == '0' }}
|
||||||
run: |
|
run: |
|
||||||
nix run ${{ github.action_path }} -- \
|
nix run ${{ github.action_path }} -- \
|
||||||
create-release \
|
create-release \
|
||||||
|
|||||||
6
setup.py
6
setup.py
@@ -1,6 +0,0 @@
|
|||||||
from setuptools import setup
|
|
||||||
|
|
||||||
setup(
|
|
||||||
name='release-action',
|
|
||||||
version='0.0.1.dev0',
|
|
||||||
)
|
|
||||||
11
src/main.py
11
src/main.py
@@ -82,7 +82,7 @@ def dump_project_description(project_description: ProjectDescription):
|
|||||||
print(' release version name: %s' % release_info.version_str)
|
print(' release version name: %s' % release_info.version_str)
|
||||||
|
|
||||||
elif isinstance(generated, Wheel):
|
elif isinstance(generated, Wheel):
|
||||||
print(' - wheel: %s' % generated.pattern)
|
print(' - wheel: %s' % generated.filename)
|
||||||
print(' repository: %s' % generated.repository)
|
print(' repository: %s' % generated.repository)
|
||||||
print(' release version name: %s' % release_info.version_str)
|
print(' release version name: %s' % release_info.version_str)
|
||||||
|
|
||||||
@@ -152,7 +152,6 @@ def make_artefact(type: str,
|
|||||||
name: str,
|
name: str,
|
||||||
filename: str,
|
filename: str,
|
||||||
package_name: str,
|
package_name: str,
|
||||||
pattern: str,
|
|
||||||
directory: str,
|
directory: str,
|
||||||
version_descriptor) -> ArtefactDescription:
|
version_descriptor) -> ArtefactDescription:
|
||||||
|
|
||||||
@@ -172,8 +171,8 @@ def make_artefact(type: str,
|
|||||||
**maybe_repository)
|
**maybe_repository)
|
||||||
|
|
||||||
elif type == 'wheel':
|
elif type == 'wheel':
|
||||||
assert pattern is not None
|
assert filename is not None
|
||||||
generated = Wheel(pattern=pattern, **maybe_repository)
|
generated = Wheel(filename=filename, **maybe_repository)
|
||||||
|
|
||||||
elif type == 'sdist':
|
elif type == 'sdist':
|
||||||
assert filename is not None
|
assert filename is not None
|
||||||
@@ -248,7 +247,7 @@ def sync_versions(project_description: ProjectDescription):
|
|||||||
sync(artefact.version_descriptor)
|
sync(artefact.version_descriptor)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def main_cli():
|
||||||
parser = ArgumentParser()
|
parser = ArgumentParser()
|
||||||
parser.add_argument('action', choices=[
|
parser.add_argument('action', choices=[
|
||||||
'declare',
|
'declare',
|
||||||
@@ -297,7 +296,6 @@ if __name__ == '__main__':
|
|||||||
parser.add_argument('--artefact-name', type=nullable_string)
|
parser.add_argument('--artefact-name', type=nullable_string)
|
||||||
parser.add_argument('--artefact-package-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-filename', type=nullable_string)
|
||||||
parser.add_argument('--artefact-pattern', type=nullable_string)
|
|
||||||
parser.add_argument('--artefact-directory', type=nullable_string)
|
parser.add_argument('--artefact-directory', type=nullable_string)
|
||||||
|
|
||||||
parser.add_argument('--deployment-type',
|
parser.add_argument('--deployment-type',
|
||||||
@@ -359,7 +357,6 @@ if __name__ == '__main__':
|
|||||||
args.artefact_name,
|
args.artefact_name,
|
||||||
args.artefact_filename,
|
args.artefact_filename,
|
||||||
args.artefact_package_name,
|
args.artefact_package_name,
|
||||||
args.artefact_pattern,
|
|
||||||
args.artefact_directory,
|
args.artefact_directory,
|
||||||
args.version_descriptor)
|
args.version_descriptor)
|
||||||
|
|
||||||
|
|||||||
@@ -97,14 +97,14 @@ class Tarball:
|
|||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class WheelReleaseInfo:
|
class WheelReleaseInfo:
|
||||||
pattern: str
|
filename: str
|
||||||
repository: str
|
repository: str
|
||||||
version_str: str
|
version_str: str
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class Wheel:
|
class Wheel:
|
||||||
pattern: str
|
filename: str
|
||||||
repository: str = DEFAULT_PYPI_REPOSITORY_NAME
|
repository: str = DEFAULT_PYPI_REPOSITORY_NAME
|
||||||
|
|
||||||
def make_environment_variables(self, context, version):
|
def make_environment_variables(self, context, version):
|
||||||
@@ -112,7 +112,7 @@ class Wheel:
|
|||||||
|
|
||||||
def make_release_info(self, context: ReleaseContext, version: Version):
|
def make_release_info(self, context: ReleaseContext, version: Version):
|
||||||
return WheelReleaseInfo(
|
return WheelReleaseInfo(
|
||||||
pattern=self.pattern,
|
filename=self.filename,
|
||||||
repository=self.repository,
|
repository=self.repository,
|
||||||
version_str=python_version_str(version))
|
version_str=python_version_str(version))
|
||||||
|
|
||||||
@@ -262,7 +262,7 @@ class ProjectDescription:
|
|||||||
if self.gitea_tool is None:
|
if self.gitea_tool is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return self.gitea_tool.is_released(self.planned_version)
|
return self.gitea_tool.is_released(self.project_version)
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def gitea_tool(self):
|
def gitea_tool(self):
|
||||||
@@ -302,6 +302,8 @@ class ProjectDescription:
|
|||||||
str(self.project_version),
|
str(self.project_version),
|
||||||
'RELEASE_PROJECT_PLANNED_VERSION':
|
'RELEASE_PROJECT_PLANNED_VERSION':
|
||||||
str(self.planned_version),
|
str(self.planned_version),
|
||||||
|
'RELEASE_PROJECT_IS_RELEASED':
|
||||||
|
'1' if self.is_released else '0',
|
||||||
}]
|
}]
|
||||||
))
|
))
|
||||||
|
|
||||||
@@ -325,8 +327,8 @@ def parse_project_description(obj):
|
|||||||
**optional(tar, 'repository'))
|
**optional(tar, 'repository'))
|
||||||
|
|
||||||
def parse_wheel(whl):
|
def parse_wheel(whl):
|
||||||
assert 'pattern' in whl
|
assert 'filename' in whl
|
||||||
return Wheel(pattern=whl['pattern'],
|
return Wheel(filename=whl['filename'],
|
||||||
**optional(whl, 'repository'))
|
**optional(whl, 'repository'))
|
||||||
|
|
||||||
def parse_sdist(sdist):
|
def parse_sdist(sdist):
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ def publish_wheel(info: WheelReleaseInfo, cli: Cli):
|
|||||||
'upload',
|
'upload',
|
||||||
'--verbose',
|
'--verbose',
|
||||||
'--repository', info.repository,
|
'--repository', info.repository,
|
||||||
info.pattern)
|
info.filename)
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ artefacts:
|
|||||||
repository: balls
|
repository: balls
|
||||||
|
|
||||||
- type: wheel
|
- type: wheel
|
||||||
pattern: './scratch/wheels/*.whl'
|
filename: './scratch/wheels/*.whl'
|
||||||
|
|
||||||
- type: wheel
|
- type: wheel
|
||||||
pattern: './scratch/wheels/*.whl'
|
filename: './scratch/wheels/*.whl'
|
||||||
repository: other
|
repository: other
|
||||||
|
|
||||||
- type: sdist
|
- type: sdist
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from os import path
|
from os import path
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
from semver import Version
|
from semver import Version
|
||||||
@@ -14,6 +15,14 @@ from release.project import (ArtefactDescription, DeploymentCondition,
|
|||||||
WheelReleaseInfo, parse_project_description)
|
WheelReleaseInfo, parse_project_description)
|
||||||
|
|
||||||
|
|
||||||
|
class MockGiteaTool:
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def is_released(self, version):
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class TestProjectDescription(TestCase):
|
class TestProjectDescription(TestCase):
|
||||||
def test_can_describe_projects(self):
|
def test_can_describe_projects(self):
|
||||||
# resi-lib
|
# resi-lib
|
||||||
@@ -21,7 +30,7 @@ class TestProjectDescription(TestCase):
|
|||||||
version_descriptor='src/python/Cargo.toml',
|
version_descriptor='src/python/Cargo.toml',
|
||||||
artefacts=[
|
artefacts=[
|
||||||
ArtefactDescription(
|
ArtefactDescription(
|
||||||
generated=Wheel(pattern='./scratch/wheels/*.whl'))
|
generated=Wheel(filename='./scratch/wheels/*.whl'))
|
||||||
])
|
])
|
||||||
|
|
||||||
# productdesignerd
|
# productdesignerd
|
||||||
@@ -46,7 +55,7 @@ class TestProjectDescription(TestCase):
|
|||||||
ArtefactDescription(
|
ArtefactDescription(
|
||||||
generated=OciImage(name='masa-images')),
|
generated=OciImage(name='masa-images')),
|
||||||
ArtefactDescription(
|
ArtefactDescription(
|
||||||
generated=Wheel(pattern='./scratch/wheels/*.whl'))
|
generated=Wheel(filename='./scratch/wheels/*.whl'))
|
||||||
],
|
],
|
||||||
deployments=[
|
deployments=[
|
||||||
DeploymentDescription(
|
DeploymentDescription(
|
||||||
@@ -125,7 +134,7 @@ class TestProjectDescription(TestCase):
|
|||||||
artefacts=[
|
artefacts=[
|
||||||
ArtefactDescription(
|
ArtefactDescription(
|
||||||
version_descriptor='src/python/pyproject.toml',
|
version_descriptor='src/python/pyproject.toml',
|
||||||
generated=Wheel(pattern='./scratch/wheels/*.whl')),
|
generated=Wheel(filename='./scratch/wheels/*.whl')),
|
||||||
ArtefactDescription(generated=OciImage(name='prngl')),
|
ArtefactDescription(generated=OciImage(name='prngl')),
|
||||||
],
|
],
|
||||||
deployments=[
|
deployments=[
|
||||||
@@ -136,6 +145,7 @@ class TestProjectDescription(TestCase):
|
|||||||
namespace='prngl-testing'))
|
namespace='prngl-testing'))
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@patch('release.project.toolkit.Gitea', MockGiteaTool)
|
||||||
def test_environment_variables(self):
|
def test_environment_variables(self):
|
||||||
# motacilla
|
# motacilla
|
||||||
desc = ProjectDescription(
|
desc = ProjectDescription(
|
||||||
@@ -184,6 +194,7 @@ class TestProjectDescription(TestCase):
|
|||||||
'RELEASE_IMAGE_LOCAL_NAME_MOTACILLA_CDN':
|
'RELEASE_IMAGE_LOCAL_NAME_MOTACILLA_CDN':
|
||||||
'motacilla-cdn:0AB123',
|
'motacilla-cdn:0AB123',
|
||||||
'RELEASE_IS_PRERELEASE': '1',
|
'RELEASE_IS_PRERELEASE': '1',
|
||||||
|
'RELEASE_PROJECT_IS_RELEASED': '0',
|
||||||
'RELEASE_PROJECT_CURRENT_VERSION': '2.10.4',
|
'RELEASE_PROJECT_CURRENT_VERSION': '2.10.4',
|
||||||
'RELEASE_PROJECT_PLANNED_VERSION': '2.10.4-dev42'
|
'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')))
|
tarball.make_release_info(None, Version(1, 2, 3, 'dev4')))
|
||||||
|
|
||||||
def test_wheel_release_info(self):
|
def test_wheel_release_info(self):
|
||||||
wheel = Wheel(pattern='dist/wheels/*')
|
wheel = Wheel(filename='dist/wheels/*')
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
WheelReleaseInfo(pattern='dist/wheels/*',
|
WheelReleaseInfo(filename='dist/wheels/*',
|
||||||
repository='gitea',
|
repository='gitea',
|
||||||
version_str='1.2.3.dev4'),
|
version_str='1.2.3.dev4'),
|
||||||
wheel.make_release_info(None, Version(1, 2, 3, 'dev4')))
|
wheel.make_release_info(None, Version(1, 2, 3, 'dev4')))
|
||||||
@@ -355,9 +366,9 @@ class TestProjectDescription(TestCase):
|
|||||||
repository='balls')),
|
repository='balls')),
|
||||||
|
|
||||||
ArtefactDescription(generated=Wheel(
|
ArtefactDescription(generated=Wheel(
|
||||||
pattern='./scratch/wheels/*.whl')),
|
filename='./scratch/wheels/*.whl')),
|
||||||
ArtefactDescription(generated=Wheel(
|
ArtefactDescription(generated=Wheel(
|
||||||
pattern='./scratch/wheels/*.whl', repository='other')),
|
filename='./scratch/wheels/*.whl', repository='other')),
|
||||||
|
|
||||||
ArtefactDescription(generated=Sdist(
|
ArtefactDescription(generated=Sdist(
|
||||||
filename='./dist/papyru-0.0.1.tar.gz')),
|
filename='./dist/papyru-0.0.1.tar.gz')),
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ class Structured:
|
|||||||
for part in item_path:
|
for part in item_path:
|
||||||
cur = cur[part]
|
cur = cur[part]
|
||||||
|
|
||||||
|
self.filename = filename
|
||||||
self.format = format
|
self.format = format
|
||||||
self.item_path = item_path
|
self.item_path = item_path
|
||||||
self.content = obj
|
self.content = obj
|
||||||
|
|||||||
@@ -6,6 +6,23 @@ inputs: {}
|
|||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
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
|
- name: sync versions
|
||||||
run: |
|
run: |
|
||||||
nix run ${{ github.action_path }} -- \
|
nix run ${{ github.action_path }} -- \
|
||||||
|
|||||||
Reference in New Issue
Block a user