Håkon Pettersen
11/08/2023, 2:29 PMname: iOS Publish
on:
push:
# push:
# branches:
# - "main"
jobs:
call-kmmbridge-publish:
permissions:
contents: write
packages: write
uses: ./.github/workflows/faktory-build.yml
with:
jvmVersion: 17
libraryVersion: LIBRARY_VERSION
faktory-build.yml
name: KMM Bridge Github Workflow
on:
workflow_call:
inputs:
module:
description: The module name to run the task on if you have multiple kmp modules
required: false
type: string
publishTask:
description: 'The publish task to call if not kmmBridgePublish'
default: 'kmmBridgePublish'
required: false
type: string
jvmVersion:
description: 'JVM Version to use. Will be passed to java-version parameter of setup-java'
default: '11'
required: false
type: string
runsOn:
description: 'Host parameter to pass to runs-on'
default: 'macos-12'
required: false
type: string
libraryVersion:
description: 'Version key from gradle.properties'
required: true
type: string
retainBuildBranch:
description: 'Keep the build branch after build complete'
default: false
type: boolean
secrets:
gradle_params:
required: false
jobs:
kmmbridgepublish:
concurrency: "kmmbridgepublish-${{ github.repository }}"
runs-on: ${{ inputs.runsOn }}
env:
MODULE: ${{ inputs.module != '' && format('{0}:',inputs.module) || '' }}
USERNAME: ${{ secrets.USERNAME }}
TOKEN: ${{ secrets.TOKEN }}
steps:
- name: Checkout the repo with tags
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v2
with:
distribution: "adopt"
java-version: ${{ inputs.jvmVersion }}
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Cache build tooling
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.konan
key: ${{ runner.os }}-v4-${{ hashFiles('*.gradle.kts') }}
- name: Build Main
run: ./gradlew ${{ env.MODULE }}${{ inputs.publishTask }} -PENABLE_PUBLISHING=true -PGITHUB_PUBLISH_TOKEN=${{ secrets.GITHUB_TOKEN }} -PGITHUB_REPO=${{ github.repository }} ${{ secrets.gradle_params }} --no-daemon --stacktrace
env:
GRADLE_OPTS: -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx3g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:MaxMetaspaceSize=512m"
- uses: touchlab/autoversion-finishrelease@main
id: autoversion-finishrelease
with:
commitMessage: "Snute Shared Library SPM package release for ${{ inputs.libraryVersion }}"
tagMessage: "Snute Shared Library release version ${{ inputs.libraryVersion }}"
tagVersion: ${{ inputs.libraryVersion }}
branchName: "build-${{ inputs.libraryVersion }}"
- uses: touchlab/autoversion-tagmarker@main
id: autoversion-tagmarker-cleanup
with:
nextVersion: ${{ inputs.libraryVersion }}
cleanupMarkers: 'true'
- name: Delete branch
if: (!inputs.retainBuildBranch) && (!cancelled())
uses: touchlab/action-delete-branch@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branches: "build-${{ inputs.libraryVersion }}"
kpgalligan
11/08/2023, 3:22 PMWorkflows that call reusable workflows in the same organization or enterprise can use thekeyword to implicitly pass the secrets.inherit
jobs:
call-workflow-passing-data:
uses: octo-org/example-repo/.github/workflows/reusable-workflow.yml@main
with:
config-path: .github/labeler.yml
secrets: inherit
When a reusable workflow is triggered by a caller workflow, thecontext is always associated with the caller workflow. The called workflow is automatically granted access togithub
andgithub.token
.secrets.GITHUB_TOKEN
Håkon Pettersen
11/16/2023, 8:23 AMinherit
keyword solved the missing enviroment-variables in the reusable workflow, thanks 🙂