Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 81 additions & 1 deletion .github/workflows/gradle-publish-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ on:

permissions:
contents: write
packages: write

jobs:
build_memory_footprint:
Expand Down Expand Up @@ -61,11 +62,90 @@ jobs:
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ inputs.release_name }}"
prerelease: true
prerelease: false
title: "Memory Footprint Build"
files: |
memory-footprint_LICENSE.txt
wff-validator_LICENSE.txt
**/memory-footprint.jar
**/wff-validator.jar
**/wff-xsd.zip

publish_packages:
runs-on: ubuntu-latest
needs: build_memory_footprint
env:
GH_TOKEN: ${{ github.token }}
strategy:
matrix:
jar_file: [wff-validator.jar, memory-footprint.jar]
steps:
- name: Install GitHub CLI
run: |
sudo apt-get update
sudo apt-get install gh
- name: Download asset
run: |
gh release download --repo "$GITHUB_REPOSITORY" --pattern ${{ matrix.jar_file }}
- name: Get JAR version
id: get_version
run: |
VERSION=$(unzip -p ${{ matrix.jar_file }} META-INF/MANIFEST.MF | grep "^Version: " | cut -d' ' -f2)
if [[ -z "$VERSION" ]]; then
echo "::error file=${{ matrix.jar_file }}::Could not determine version from JAR's Manifest file"
exit 1
fi
echo "::set-output name=version::$VERSION"
- name: Determine final version
id: final_version
run: |
VERSION="${{ steps.get_version.outputs.version }}"
if ${{ inputs.release_name == 'latest' }}; then
VERSION="$VERSION-SNAPSHOT"
fi
echo "::set-output name=final_version::$VERSION"
- name: Determine artefact ID
id: artefact_id
run: |
FILE_NAME="${{ matrix.jar_file }}"
FILE_NAME_WITHOUT_EXTENSION="${FILE_NAME%.*}"
echo "::set-output name=artefact_id::$FILE_NAME_WITHOUT_EXTENSION"
- name: Check if Maven package already exists
id: check_exists
run: |
VERSION="${{ steps.final_version.outputs.final_version }}"
ARTEFACT_ID=${{ steps.artefact_id.outputs.artefact_id }}

METADATA_URL="https://maven.pkg.github.com/google/watchface/com.google.watchface/${ARTIFACT_ID}/${VERSION}/maven-metadata.xml"

if ${{ inputs.release_name == 'latest' }}; then
# SNAPSHOT version should always publish
echo "::set-output name=should_publish::true"
elif curl -s -f -o /dev/null -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "$METADATA_URL"; then
# Don't republish existing non-SNAPSHOT versions
echo "Maven package with version $VERSION already exists."
else
echo "Maven package with version $VERSION does not exist."
echo "::set-output name=should_publish::true"
fi
- name: create settings.xml
if: steps.check_exists.outputs.should_publish == 'true'
run: |
mkdir -p ~/.m2
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
shell: bash
env:
GITHUB_PATH: ~/.m2/
- name: Publish to GitHub Packages
if: steps.check_exists.outputs.should_publish == 'true'
run: |
mvn deploy:deploy-file \
-DgroupId=com.google.watchface \
-DartifactId=${{ steps.artefact_id.outputs.artefact_id }} \
-Dversion=${{ steps.final_version.outputs.final_version }} \
-Dpackaging=jar \
-Dfile=${{ matrix.jar_file }} \
-Durl=https://maven.pkg.github.com/google/watchface \
-DrepositoryId=github -s ~/.m2/settings.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .github/workflows/gradle-publish-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:

permissions:
contents: write
packages: write

jobs:
call-publish-base:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/gradle-publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ on:

permissions:
contents: write
packages: write

jobs:
call-publish-base:
Expand Down
Loading