Files

98 lines
3.1 KiB
YAML

# Publishes the konfig Gradle plugin to GitHub Packages and maven.bitsycore.com
# whenever a version tag (e.g. 0.6.0) is pushed. The tag is the single source
# of truth for the published version. A GitHub release is created afterwards.
name: Publish
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+'
workflow_dispatch:
inputs:
version:
description: 'Version to publish (e.g. 0.6.0)'
required: true
type: string
concurrency:
group: publish-${{ github.ref }}
cancel-in-progress: false
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write # create the GitHub release
packages: write # push to GitHub Packages with GITHUB_TOKEN
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
- name: Set up Android SDK
uses: android-actions/setup-android@v3
- name: Install Android test SDK
run: sdkmanager 'platforms;android-35' 'build-tools;35.0.0' 'build-tools;36.0.0'
- name: Resolve version
id: version
run: |
if [ "${{ github.ref_type }}" = "tag" ]; then
VERSION="${GITHUB_REF_NAME#v}"
else
VERSION="${{ inputs.version }}"
fi
if [ -z "$VERSION" ]; then
echo "::error::No version could be resolved." && exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Publishing version: $VERSION"
- name: Run tests
run: ./gradlew check -Pkonfig.version=${{ steps.version.outputs.version }}
- name: Publish to GitHub Packages
env:
GPR_USER: ${{ github.actor }}
GPR_KEY: ${{ secrets.GITHUB_TOKEN }}
run: >
./gradlew publishAllPublicationsToGitHubPackagesRepository
-Pkonfig.version=${{ steps.version.outputs.version }}
--stacktrace
- name: Publish to maven.bitsycore.com
env:
BITSYCORE_MAVEN_USER: ${{ secrets.BITSYCORE_MAVEN_USER }}
BITSYCORE_MAVEN_TOKEN: ${{ secrets.BITSYCORE_MAVEN_TOKEN }}
run: >
./gradlew publishAllPublicationsToBitsycoreRepository
-Pkonfig.version=${{ steps.version.outputs.version }}
--stacktrace
# Create the GitHub release once both publishes succeeded (skipped if it
# already exists, e.g. created by hand beforehand).
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION="${{ steps.version.outputs.version }}"
if gh release view "$VERSION" --repo "$GITHUB_REPOSITORY" > /dev/null 2>&1; then
echo "Release $VERSION already exists - skipping."
else
gh release create "$VERSION" \
--repo "$GITHUB_REPOSITORY" \
--title "$VERSION" \
--generate-notes
fi