Skip to content

Publish

Publish #59

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: '11'
distribution: temurin
cache: gradle
- name: Setup Android SDK
uses: android-actions/setup-android@7c5672355aaa8fde5f97a91aa9a99616d1ace6bc
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@55e685c48d84285a5b0418cd094606e199cca3b6
- 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: '1.0.0'
- run: "echo \"No feature or fix commits. Skipping build...\""
if: "${{ steps.version-check.outputs.version == '1.0.0' }}"
- uses: andymckay/cancel-action@0.3
if: "${{ steps.version-check.outputs.version == '1.0.0' }}"
- name: "Wait for cancel to stick"
run: "sleep 99999"
if: "${{ steps.version-check.outputs.version == '1.0.0' }}"
- run: "./bump_version.sh"
- 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'
- name: 'Publish'
run: './gradlew publish :kotlinova-gradle:publish
-PossrhUsername=''${{ secrets.OSSRH_USERNAME }}''
-PossrhPassword=''${{ secrets.OSSRH_PASSWORD }}''
-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
-PossrhUsername=''${{ secrets.OSSRH_USERNAME }}''
-PossrhPassword=''${{ secrets.OSSRH_PASSWORD }}'''
- 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