Skip to content

Publish

Publish #78

Workflow file for this run

name: publish
run-name: "Publish"
on:
push:
branches:
- master
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: "v=$(cat version.txt);echo \"OLD_VERSION=$v\" > $GITHUB_ENV"
- name: Check if there were any new fix or feature commits
id: version-check
uses: inovait/actions-common/bump-version-since-last-build@21a4069c8686686b5d0a1429f4d1f7ebf0d59f1a
with:
version: '${{ env.OLD_VERSION }}'
- run: "echo \"No feature or fix commits. Skipping build...\""
if: "${{ steps.version-check.outputs.version == env.OLD_VERSION }}"
- uses: andymckay/cancel-action@0.3
if: "${{ steps.version-check.outputs.version == env.OLD_VERSION }}"
- name: "Wait for cancel to stick"
run: "sleep 99999"
if: "${{ steps.version-check.outputs.version == env.OLD_VERSION }}"
- run: "./bump_version.sh ${{ steps.version-check.outputs.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: Generate Changelog
id: changelog
uses: inovait/actions-common/changelog-since-last-build@21a4069c8686686b5d0a1429f4d1f7ebf0d59f1a
with:
git_commit_url_prefix: 'https://github.com/inovait/kotlinova/commit/'
- run: "old_changelog=$(cat CHANGELOG.MD); echo \"# ${{ env.VERSION }}\n\n${{ steps.changelog.outputs.changelog }}\n\n$old_changelog\" > CHANGELOG.MD"
- 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: 'Add changelog and version'
run: 'git add version.txt CHANGELOG.MD'
- run: 'git config --global user.email "ci@inova.si"'
- run: 'git config --global user.name "Build Bot"'
- name: 'Commit changelog and version'
run: 'git commit -m "chore: release ${{ env.VERSION }}"'
- name: 'Push changelog and version'
run: 'git push'
- name: 'Create tag'
run: 'git tag ${{ env.VERSION }}'
- name: 'Push tag'
run: 'git push origin ${{ env.VERSION }}'
- name: Create a Release
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: ${{ env.VERSION }}
tag: ${{ env.VERSION }}
body: ${{ steps.changelog.outputs.changelog }}
- 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