Publish CLI to GitHub Packages #32
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish CLI to GitHub Packages | |
on: | |
release: | |
types: [created] | |
permissions: | |
contents: read | |
packages: write | |
jobs: | |
publish-cli: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- uses: actions/cache@v3 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Extract and Verify Version | |
id: version | |
run: | | |
VERSION=$(grep "^VERSION=" version.properties | cut -d'=' -f2) | |
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
echo "Publishing version: $VERSION" | |
# Check if summon-cli version already exists in GitHub Packages | |
if curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
"https://api.github.com/repos/${{ github.repository }}/packages/maven/io.github.codeyousef.summon-cli/versions" | \ | |
grep -q "\"name\":\"$VERSION\""; then | |
echo "::warning::Version $VERSION of summon-cli already exists in GitHub Packages" | |
fi | |
- name: Build CLI | |
run: ./gradlew summon-cli:build | |
- name: Publish CLI to GitHub Packages | |
run: ./gradlew summon-cli:publishCliPublicationToGitHubPackagesRepository | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |