@@ -43,12 +43,12 @@ jobs:
4343 uses : gradle/actions/setup-gradle@v3
4444 with :
4545 build-root-directory : play-validations
46- arguments : memory-footprint:jar -Dmemory-footprint.git_hash=${{ env.git_hash }}
46+ arguments : memory-footprint:build -Dmemory-footprint.git_hash=${{ env.git_hash }}
4747 - name : Build wff-validator
4848 uses : gradle/actions/setup-gradle@v3
4949 with :
50- build-root-directory : third_party/wff
51- arguments : :specification: validator:build
50+ build-root-directory : play-validations
51+ arguments : validator:build
5252 - name : Copy LICENSE files
5353 run : |
5454 mv LICENSE.txt memory-footprint_LICENSE.txt
7070 **/memory-footprint.jar
7171 **/wff-validator.jar
7272 **/wff-xsd.zip
73-
74- publish_packages :
75- runs-on : ubuntu-latest
76- needs : build_memory_footprint
77- env :
78- GH_TOKEN : ${{ github.token }}
79- strategy :
80- matrix :
81- jar_file : [wff-validator.jar, memory-footprint.jar]
82- steps :
83- - name : Install GitHub CLI
84- run : |
85- sudo apt-get update
86- sudo apt-get install gh
87- - name : Download asset
88- run : |
89- gh release download --repo "$GITHUB_REPOSITORY" --pattern ${{ matrix.jar_file }}
90- - name : Get JAR version
91- id : get_version
92- run : |
93- VERSION=$(unzip -p ${{ matrix.jar_file }} META-INF/MANIFEST.MF | grep "^Version: " | cut -d' ' -f2)
94- if [[ -z "$VERSION" ]]; then
95- echo "::error file=${{ matrix.jar_file }}::Could not determine version from JAR's Manifest file"
96- exit 1
97- fi
98- echo "::set-output name=version::$VERSION"
99- - name : Determine final version
100- id : final_version
101- run : |
102- VERSION="${{ steps.get_version.outputs.version }}"
103- if ${{ inputs.release_name == 'latest' }}; then
104- VERSION="$VERSION-SNAPSHOT"
105- fi
106- echo "::set-output name=final_version::$VERSION"
107- - name : Determine artifact ID
108- id : artifact_id
109- run : |
110- FILE_NAME="${{ matrix.jar_file }}"
111- FILE_NAME_WITHOUT_EXTENSION="${FILE_NAME%.*}"
112- echo "::set-output name=artifact_id::$FILE_NAME_WITHOUT_EXTENSION"
113- - name : Check if Maven package already exists
114- id : check_exists
115- run : |
116- VERSION="${{ steps.final_version.outputs.final_version }}"
117- ARTIFACT_ID=${{ steps.artifact_id.outputs.artifact_id }}
118-
119- METADATA_URL="https://maven.pkg.github.com/google/watchface/com.google.watchface/${ARTIFACT_ID}/${VERSION}/maven-metadata.xml"
120-
121- if ${{ inputs.release_name == 'latest' }}; then
122- # SNAPSHOT version should always publish
123- echo "::set-output name=should_publish::true"
124- elif curl -s -f -o /dev/null -w "%{http_code}" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "$METADATA_URL" | grep -q "^200$"; then
125- # Don't republish existing non-SNAPSHOT versions
126- echo "Maven package with version $VERSION already exists."
127- else
128- echo "Maven package with version $VERSION does not exist."
129- echo "::set-output name=should_publish::true"
130- fi
131- - name : create settings.xml
132- if : steps.check_exists.outputs.should_publish == 'true'
133- run : |
134- mkdir -p ~/.m2
135- echo "<settings><servers><server><id>github</id><configuration><httpHeaders><property><name>Authorization</name><value>Bearer ${{ secrets.GITHUB_TOKEN }}</value></property></httpHeaders></configuration></server></servers></settings>" > ~/.m2/settings.xml
136- shell : bash
137- env :
138- GITHUB_PATH : ~/.m2/
139- - name : Publish to GitHub Packages
140- if : steps.check_exists.outputs.should_publish == 'true'
141- run : |
142- mvn deploy:deploy-file \
143- -DgroupId=com.google.watchface \
144- -DartifactId=${{ steps.artifact_id.outputs.artifact_id }} \
145- -Dversion=${{ steps.final_version.outputs.final_version }} \
146- -Dpackaging=jar \
147- -Dfile=${{ matrix.jar_file }} \
148- -Durl=https://maven.pkg.github.com/google/watchface \
149- -DrepositoryId=github -s ~/.m2/settings.xml
150- env :
151- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments