diff --git a/.env.dist b/.env.dist index 63f0d24..c18066c 100644 --- a/.env.dist +++ b/.env.dist @@ -1,4 +1,4 @@ -PHP_VERSION="8.3.7-1" +PHP_VERSION="8.3.10-1" -BUILD_DIRECTORY=".build" -BUILD_FILE_NAME="package.zip" +directory=".build" +file="package.zip" diff --git a/.env.example b/.env.example index 63f0d24..c18066c 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ -PHP_VERSION="8.3.7-1" +PHP_VERSION="8.3.10-1" -BUILD_DIRECTORY=".build" -BUILD_FILE_NAME="package.zip" +directory=".build" +file="package.zip" diff --git a/README.md b/README.md index 2a73f4b..bd2e993 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

- github gitea actions + github gitea actions

# Building a composer package in GitHub Action @@ -16,31 +16,31 @@ With this GitHub Action, you can build a package for the PHP Composer package ma ```yaml steps: - uses: actions/checkout@v4 - - uses: rosven9856/composer-package-action@0.1.0 + - uses: rosven9856/composer-package-action@0.1.4 id: composer_package with: - BUILD_DIRECTORY_NAME: '' - BUILD_FILE_NAME: '' - - run: echo ${{ steps.composer_package.outputs.path }} - - run: echo ${{ steps.composer_package.outputs.directory }} + directory: '' + file: '' + - run: echo ${{ steps.composer_package.outputs.file_path }} + - run: echo ${{ steps.composer_package.outputs.directory_path }} ``` ### Inputs -#### `BUILD_DIRECTORY_NAME` +#### `directory` The name of the directory for package building Default value: *.build* -#### `BUILD_FILE_NAME` +#### `file` The name of the built package file Default value: *package.zip* ### Outputs -#### `directory` +#### `directory_path` The path to the building directory -#### `path` +#### `file_path` The path to the compiled package archive diff --git a/action.yml b/action.yml index 70948f0..21b2468 100644 --- a/action.yml +++ b/action.yml @@ -1,10 +1,10 @@ name: "Composer package action" description: "With this GitHub Action, you can build a package for the PHP Composer package manager." inputs: - BUILD_DIRECTORY_NAME: + directory: description: "The name of the directory for package building" default: ".build" - BUILD_FILE_NAME: + file: description: "The name of the built package file" default: "package.zip" outputs: @@ -16,8 +16,8 @@ runs: using: "docker" image: "action.Dockerfile" args: - - ${{ inputs.BUILD_DIRECTORY_NAME }} - - ${{ inputs.BUILD_FILE_NAME }} + - ${{ inputs.directory }} + - ${{ inputs.file }} branding: icon: 'package' color: 'purple' diff --git a/compose.yml b/compose.yml index d096300..1551fbd 100644 --- a/compose.yml +++ b/compose.yml @@ -6,7 +6,7 @@ services: args: PHP_VERSION: ${PHP_VERSION} environment: - BUILD_DIRECTORY: ${BUILD_DIRECTORY} - BUILD_FILE_NAME: ${BUILD_FILE_NAME} + directory: ${directory} + file: ${file} volumes: - .:/usr/bin/app diff --git a/docs/img/github_gitea_actions.jpg b/docs/img/github_gitea_actions.jpg new file mode 100644 index 0000000..6c363ea Binary files /dev/null and b/docs/img/github_gitea_actions.jpg differ diff --git a/src/Action.php b/src/Action.php index 90aec23..669c054 100644 --- a/src/Action.php +++ b/src/Action.php @@ -79,12 +79,12 @@ public function run(): void $GITHUB_OUTPUT = (string) $this->configuration->get('GITHUB_OUTPUT'); if (!empty($GITHUB_OUTPUT)) { - $name = 'directory'; + $name = 'directory_path'; $value = (string) $this->configuration->get('build.directory'); file_put_contents($GITHUB_OUTPUT, "{$name}={$value}\n", FILE_APPEND); - $name = 'path'; + $name = 'file_path'; $value = (string) $this->configuration->get('build.file'); file_put_contents($GITHUB_OUTPUT, "{$name}={$value}\n", FILE_APPEND); diff --git a/src/Configuration/Configuration.php b/src/Configuration/Configuration.php index c76c101..d4597f1 100644 --- a/src/Configuration/Configuration.php +++ b/src/Configuration/Configuration.php @@ -15,8 +15,8 @@ public function __construct() { $GITHUB_WORKSPACE = (string) getenv('GITHUB_WORKSPACE'); $GITHUB_OUTPUT = (string) getenv('GITHUB_OUTPUT'); - $dirName = (string) getenv('BUILD_DIRECTORY_NAME'); - $fileName = (string) getenv('BUILD_FILE_NAME'); + $dirName = (string) getenv('directory'); + $fileName = (string) getenv('file'); $GITHUB_WORKSPACE = !empty($GITHUB_WORKSPACE) ? $GITHUB_WORKSPACE : realpath(__DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . '..'); $GITHUB_OUTPUT = !empty($GITHUB_OUTPUT) ? $GITHUB_OUTPUT : $GITHUB_WORKSPACE . \DIRECTORY_SEPARATOR . 'var' . \DIRECTORY_SEPARATOR . 'outputcmd.txt'; diff --git a/tests/Configuration/ConfigurationTest.php b/tests/Configuration/ConfigurationTest.php index 05a7c4c..e7e1fa6 100644 --- a/tests/Configuration/ConfigurationTest.php +++ b/tests/Configuration/ConfigurationTest.php @@ -24,12 +24,12 @@ final class ConfigurationTest extends TestCase /** * @var string */ - private const string DEFAULT_ENV_BUILD_DIRECTORY_NAME = '.build'; + private const string DEFAULT_ENV_DIRECTORY = '.build'; /** * @var string */ - private const string DEFAULT_ENV_BUILD_FILE_NAME = 'package.zip'; + private const string DEFAULT_ENV_FILE = 'package.zip'; /** * @var string @@ -44,12 +44,12 @@ final class ConfigurationTest extends TestCase /** * @var string */ - private const string OTHER_ENV_BUILD_DIRECTORY_NAME = '.build_directory'; + private const string OTHER_ENV_DIRECTORY = '.build_directory'; /** * @var string */ - private const string OTHER_ENV_BUILD_FILE_NAME = 'build_file.zip'; + private const string OTHER_ENV_FILE = 'build_file.zip'; // protected Configuration $configuration; @@ -68,8 +68,8 @@ public function testCheckDefaultOptionGitHubWorkspace(): void { putenv('GITHUB_WORKSPACE=' . self::DEFAULT_ENV_GITHUB_WORKSPACE); putenv('GITHUB_OUTPUT=' . self::DEFAULT_ENV_GITHUB_OUTPUT); - putenv('BUILD_DIRECTORY_NAME=' . self::DEFAULT_ENV_BUILD_DIRECTORY_NAME); - putenv('BUILD_FILE_NAME=' . self::DEFAULT_ENV_BUILD_FILE_NAME); + putenv('directory=' . self::DEFAULT_ENV_DIRECTORY); + putenv('file=' . self::DEFAULT_ENV_FILE); $configuration = new Configuration(); @@ -86,8 +86,8 @@ public function testCheckDefaultGetRootDirectory(): void { putenv('GITHUB_WORKSPACE=' . self::DEFAULT_ENV_GITHUB_WORKSPACE); putenv('GITHUB_OUTPUT=' . self::DEFAULT_ENV_GITHUB_OUTPUT); - putenv('BUILD_DIRECTORY_NAME=' . self::DEFAULT_ENV_BUILD_DIRECTORY_NAME); - putenv('BUILD_FILE_NAME=' . self::DEFAULT_ENV_BUILD_FILE_NAME); + putenv('directory=' . self::DEFAULT_ENV_DIRECTORY); + putenv('file=' . self::DEFAULT_ENV_FILE); $configuration = new Configuration(); @@ -104,8 +104,8 @@ public function testCheckDefaultOptionGitHubOutput(): void { putenv('GITHUB_WORKSPACE=' . self::DEFAULT_ENV_GITHUB_WORKSPACE); putenv('GITHUB_OUTPUT=' . self::DEFAULT_ENV_GITHUB_OUTPUT); - putenv('BUILD_DIRECTORY_NAME=' . self::DEFAULT_ENV_BUILD_DIRECTORY_NAME); - putenv('BUILD_FILE_NAME=' . self::DEFAULT_ENV_BUILD_FILE_NAME); + putenv('directory=' . self::DEFAULT_ENV_DIRECTORY); + putenv('file=' . self::DEFAULT_ENV_FILE); $configuration = new Configuration(); @@ -122,14 +122,14 @@ public function testCheckDefaultOptionBuildDirectory(): void { putenv('GITHUB_WORKSPACE=' . self::DEFAULT_ENV_GITHUB_WORKSPACE); putenv('GITHUB_OUTPUT=' . self::DEFAULT_ENV_GITHUB_OUTPUT); - putenv('BUILD_DIRECTORY_NAME=' . self::DEFAULT_ENV_BUILD_DIRECTORY_NAME); - putenv('BUILD_FILE_NAME=' . self::DEFAULT_ENV_BUILD_FILE_NAME); + putenv('directory=' . self::DEFAULT_ENV_DIRECTORY); + putenv('file=' . self::DEFAULT_ENV_FILE); $configuration = new Configuration(); self::assertEquals( $configuration->get('build.directory'), - self::DEFAULT_ENV_GITHUB_WORKSPACE . \DIRECTORY_SEPARATOR . self::DEFAULT_ENV_BUILD_DIRECTORY_NAME, + self::DEFAULT_ENV_GITHUB_WORKSPACE . \DIRECTORY_SEPARATOR . self::DEFAULT_ENV_DIRECTORY, ); } @@ -140,15 +140,15 @@ public function testCheckDefaultOptionBuildFile(): void { putenv('GITHUB_WORKSPACE=' . self::DEFAULT_ENV_GITHUB_WORKSPACE); putenv('GITHUB_OUTPUT=' . self::DEFAULT_ENV_GITHUB_OUTPUT); - putenv('BUILD_DIRECTORY_NAME=' . self::DEFAULT_ENV_BUILD_DIRECTORY_NAME); - putenv('BUILD_FILE_NAME=' . self::DEFAULT_ENV_BUILD_FILE_NAME); + putenv('directory=' . self::DEFAULT_ENV_DIRECTORY); + putenv('file=' . self::DEFAULT_ENV_FILE); $configuration = new Configuration(); self::assertEquals( $configuration->get('build.file'), - self::DEFAULT_ENV_GITHUB_WORKSPACE . \DIRECTORY_SEPARATOR . self::DEFAULT_ENV_BUILD_DIRECTORY_NAME . - \DIRECTORY_SEPARATOR . self::DEFAULT_ENV_BUILD_FILE_NAME, + self::DEFAULT_ENV_GITHUB_WORKSPACE . \DIRECTORY_SEPARATOR . self::DEFAULT_ENV_DIRECTORY . + \DIRECTORY_SEPARATOR . self::DEFAULT_ENV_FILE, ); } @@ -159,8 +159,8 @@ public function testCheckOtherOptionOptionGitHubOutput(): void { putenv('GITHUB_WORKSPACE=' . self::OTHER_ENV_GITHUB_WORKSPACE); putenv('GITHUB_OUTPUT=' . self::OTHER_ENV_GITHUB_OUTPUT); - putenv('BUILD_DIRECTORY_NAME=' . self::OTHER_ENV_BUILD_DIRECTORY_NAME); - putenv('BUILD_FILE_NAME=' . self::OTHER_ENV_BUILD_FILE_NAME); + putenv('directory=' . self::OTHER_ENV_DIRECTORY); + putenv('file=' . self::OTHER_ENV_FILE); $configuration = new Configuration(); @@ -177,8 +177,8 @@ public function testCheckOtherGetRootDirectory(): void { putenv('GITHUB_WORKSPACE=' . self::OTHER_ENV_GITHUB_WORKSPACE); putenv('GITHUB_OUTPUT=' . self::OTHER_ENV_GITHUB_OUTPUT); - putenv('BUILD_DIRECTORY_NAME=' . self::OTHER_ENV_BUILD_DIRECTORY_NAME); - putenv('BUILD_FILE_NAME=' . self::OTHER_ENV_BUILD_FILE_NAME); + putenv('directory=' . self::OTHER_ENV_DIRECTORY); + putenv('file=' . self::OTHER_ENV_FILE); $configuration = new Configuration(); @@ -195,8 +195,8 @@ public function testCheckOtherOptionGitHubOutput(): void { putenv('GITHUB_WORKSPACE=' . self::OTHER_ENV_GITHUB_WORKSPACE); putenv('GITHUB_OUTPUT=' . self::OTHER_ENV_GITHUB_OUTPUT); - putenv('BUILD_DIRECTORY_NAME=' . self::OTHER_ENV_BUILD_DIRECTORY_NAME); - putenv('BUILD_FILE_NAME=' . self::OTHER_ENV_BUILD_FILE_NAME); + putenv('directory=' . self::OTHER_ENV_DIRECTORY); + putenv('file=' . self::OTHER_ENV_FILE); $configuration = new Configuration(); @@ -213,14 +213,14 @@ public function testCheckOtherOptionBuildDirectory(): void { putenv('GITHUB_WORKSPACE=' . self::OTHER_ENV_GITHUB_WORKSPACE); putenv('GITHUB_OUTPUT=' . self::OTHER_ENV_GITHUB_OUTPUT); - putenv('BUILD_DIRECTORY_NAME=' . self::OTHER_ENV_BUILD_DIRECTORY_NAME); - putenv('BUILD_FILE_NAME=' . self::OTHER_ENV_BUILD_FILE_NAME); + putenv('directory=' . self::OTHER_ENV_DIRECTORY); + putenv('file=' . self::OTHER_ENV_FILE); $configuration = new Configuration(); self::assertEquals( $configuration->get('build.directory'), - self::OTHER_ENV_GITHUB_WORKSPACE . \DIRECTORY_SEPARATOR . self::OTHER_ENV_BUILD_DIRECTORY_NAME, + self::OTHER_ENV_GITHUB_WORKSPACE . \DIRECTORY_SEPARATOR . self::OTHER_ENV_DIRECTORY, ); } @@ -231,15 +231,15 @@ public function testCheckOtherOptionBuildFile(): void { putenv('GITHUB_WORKSPACE=' . self::OTHER_ENV_GITHUB_WORKSPACE); putenv('GITHUB_OUTPUT=' . self::OTHER_ENV_GITHUB_OUTPUT); - putenv('BUILD_DIRECTORY_NAME=' . self::OTHER_ENV_BUILD_DIRECTORY_NAME); - putenv('BUILD_FILE_NAME=' . self::OTHER_ENV_BUILD_FILE_NAME); + putenv('directory=' . self::OTHER_ENV_DIRECTORY); + putenv('file=' . self::OTHER_ENV_FILE); $configuration = new Configuration(); self::assertEquals( $configuration->get('build.file'), - self::OTHER_ENV_GITHUB_WORKSPACE . \DIRECTORY_SEPARATOR . self::OTHER_ENV_BUILD_DIRECTORY_NAME . - \DIRECTORY_SEPARATOR . self::OTHER_ENV_BUILD_FILE_NAME, + self::OTHER_ENV_GITHUB_WORKSPACE . \DIRECTORY_SEPARATOR . self::OTHER_ENV_DIRECTORY . + \DIRECTORY_SEPARATOR . self::OTHER_ENV_FILE, ); } }