Skip to content

Commit

Permalink
Make sure gradle properties are on the same line (#10)
Browse files Browse the repository at this point in the history
Previously we needed arguments on multiple lines but now we call
gradlew from bash.
  • Loading branch information
Chris-V authored Aug 7, 2024
1 parent 9bae95c commit 0abc8f9
Showing 1 changed file with 25 additions and 35 deletions.
60 changes: 25 additions & 35 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,48 +43,39 @@ inputs:
runs:
using: "composite"
steps:
- name: Lookup properties
- name: Process gradle properties
id: properties
shell: bash
shell: python
env:
INPUT_GENERATOR_NAME: ${{ inputs.generator-name }}
INPUT_GRADLE_PROPERTIES: ${{ inputs.gradle-properties }}
INPUT_IS_RELEASE: ${{ inputs.is-release }}
INPUT_OPENAPI_SPEC_FILE: ${{ inputs.openapi-spec-file }}
INPUT_PUBLISH: ${{ inputs.publish }}
INPUT_PUBLISH_PAT: ${{ inputs.publish-pat }}
run: |
PROPERTIES=(
is-release=${{ inputs.is-release }}
)
TASK=build
GENERATOR=${{ inputs.generator-name }}
GENERATOR=${GENERATOR,,}
GENERATOR=${GENERATOR^}
if [[ "${{ inputs.publish }}" == "true" ]]; then
TASK=publish
PROPERTIES+=(gpr.write.key=${{ inputs.publish-pat }});
import os
import subprocess
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
fi
task = 'build'
generator = os.environ.get('INPUT_GENERATOR_NAME').title()
properties = [ '-Pis-release=' + os.environ.get('INPUT_IS_RELEASE') ]
if [[ "${{ inputs.openapi-spec-file }}" != "" ]]; then
PROPERTIES+=(openApiSpec=${{ inputs.openapi-spec-file }});
fi
if os.environ.get('INPUT_PUBLISH') == 'true':
task = 'publish'
properties.append('-Pgpr.write.key=' + os.environ.get('INPUT_PUBLISH_PAT'))
echo "task-name=${TASK}${GENERATOR}Sdk" >> $GITHUB_OUTPUT
echo "PROPERTIES<<EOF" >> $GITHUB_ENV
printf -- "-P%s\n" "${PROPERTIES[@]}" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
subprocess.run(['git', 'config', '--global', 'user.email', '41898282+github-actions[bot]@users.noreply.github.com'])
subprocess.run(['git', 'config', '--global', 'user.name', 'github-actions[bot]'])
- name: Process gradle properties
id: gradle-properties
shell: python
env:
GRADLE_PROPERTIES: ${{ inputs.gradle-properties }}
run: |
import os
if os.environ.get('INPUT_OPENAPI_SPEC_FILE'):
properties.append('-PopenApiSpec=' + os.environ.get('INPUT_OPENAPI_SPEC_FILE'))
properties_list: list[str] = [line for line in (line.strip() for line in os.environ.get('GRADLE_PROPERTIES').splitlines()) if line]
properties = list(map(lambda x: f'-P{x}' if not x.startswith('-P') else x, properties_list))
properties_input: list[str] = [line for line in (line.strip() for line in os.environ.get('INPUT_GRADLE_PROPERTIES').splitlines()) if line]
properties.extend(map(lambda x: f'-P{x}' if not x.startswith('-P') else x, properties_input))
with open(os.environ.get('GITHUB_OUTPUT'), 'a') as output_file:
output_file.write(f'task-name={task}{generator}Sdk\n')
output_file.write('gradle-properties=')
output_file.write(' '.join(properties))
output_file.write('\n')
Expand All @@ -101,5 +92,4 @@ runs:
./gradlew \
-p ${{ inputs.gradle-project-path }} \
${{ steps.properties.outputs.task-name }} \
${{ env.PROPERTIES }} \
${{ steps.gradle-properties.outputs.gradle-properties }}
${{ steps.properties.outputs.gradle-properties }}

0 comments on commit 0abc8f9

Please sign in to comment.