Skip to content

Commit

Permalink
ci: add manual publish
Browse files Browse the repository at this point in the history
  • Loading branch information
matejdro committed Oct 25, 2024
1 parent f8a3b8f commit e01c3f2
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/publish-manual.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Manual publish workflow that publishes a library version from any branch with the specified version
name: publish-manual
run-name: "Manual publish"
on:
workflow_dispatch:
inputs:
version:
description: 'Version to publish'
required: true
jobs:
build-app:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
runs-on: "ubuntu-latest"
env:
BUILD_NUMBER: ${{ github.run_number }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: temurin
cache: gradle
- name: Setup Android SDK
uses: android-actions/setup-android@7c5672355aaa8fde5f97a91aa9a99616d1ace6bc
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@55e685c48d84285a5b0418cd094606e199cca3b6
- run: "./bump_version.sh ${{ github.event.inputs.version }}"
- run: "v=$(cat version.txt);echo \"VERSION=$v\" > $GITHUB_ENV"
- run: "echo \"# Release version ${{ env.VERSION }}\" > $GITHUB_STEP_SUMMARY"
- name: Compile library
run: "./gradlew --parallel assemble :kotlinova-gradle:jar"
- name: Compile Unit Tests
# We cannot run instrumented tests on CI, but at least we can compile them to ensure
# that anvil build passes.
run: "./gradlew --parallel jvmTestClasses compileDebugUnitTestKotlinAndroid compileReleaseUnitTestKotlinAndroid assembleAndroidTest testClasses"
- name: Lint
run: "./gradlew --continue --parallel buildSrc:detekt detektMetadataMain detektJvmMain detektAndroidDebug detektAndroidRelease detektJvmTest :kotlinova-gradle:detektMain lint"
- name: Run Unit Tests
run: "./gradlew test jvmTest"
- name: 'Save GPG key'
run: 'echo "${{ secrets.GPG_SIGNING_KEY }}" | base64 -d > signing_key.gpg'
- id: create_staging_repository
name: "Create nexus staging repository"
uses: nexus-actions/create-nexus-staging-repo@v1.2
with:
# The username you use to connect to Sonatype's Jira
username: ${{ secrets.OSSRH_USERNAME }}
password: ${{ secrets.OSSRH_PASSWORD }}
# Your staging profile ID. You can get it at https://oss.sonatype.org/#stagingProfiles;$staginProfileId
staging_profile_id: ${{ secrets.OSSRH_STAGING_PROFILE_ID }}
# a description to identify your repository in the UI
description: Created by Automatic Github flow
- name: 'Publish'
run: './gradlew publish :kotlinova-gradle:publish
-PossrhUsername=''${{ secrets.OSSRH_USERNAME }}''
-PossrhPassword=''${{ secrets.OSSRH_PASSWORD }}''
-PossrhRepId=''${{ steps.create_staging_repository.outputs.repository_id }}''
-Psigning.secretKeyRingFile=$(pwd)/signing_key.gpg
-Psigning.password=''${{ secrets.GPG_SIGNING_PASSPHRASE }}''
-Psigning.keyId=${{ secrets.GPG_SIGNING_ID }}'
- name: 'Release staging repository'
run: './gradlew closeAndReleaseRepository
-PossrhRepId=''${{ steps.create_staging_repository.outputs.repository_id }}''
-PossrhUsername=''${{ secrets.OSSRH_USERNAME }}''
-PossrhPassword=''${{ secrets.OSSRH_PASSWORD }}'''
- name: Discard nexus staging repository
if: ${{ failure() && steps.create_staging_repository.outputs.repository_id != null }}
uses: nexus-actions/drop-nexus-staging-repo@v1
with:
username: ${{ secrets.SONATYPE_USERNAME }}
password: ${{ secrets.SONATYPE_PASSWORD }}
staging_repository_id: ${{ steps.create_staging_repository.outputs.repository_id }}
- name: 'Create tag'
run: 'git tag ${{ env.VERSION }}'
- name: 'Push tag'
run: 'git push origin ${{ env.VERSION }}'
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/composite@v2
if: always()
with:
comment_mode: failures
junit_files: |
**/build/outputs/*-results/**/*.xml
**/build/*-results/**/*.xml

0 comments on commit e01c3f2

Please sign in to comment.