name: Publish Flutter Package on: workflow_call: inputs: repository: description: 'sdk repository, defaults to current repository' required: false type: string ref: description: 'commit/tag/branch reference' required: true type: string package-version: description: 'version for the flutter package (MAJOR.MINOR.BUILD) (no v prefix)' required: true type: string publish: description: 'value indicating whether to commit/tag a release.' required: true type: boolean default: true secrets: REPO_SSH_KEY: description: 'ssh key to commit to the breez-liquid-sdk-flutter repository' required: true SWIFT_RELEASE_TOKEN: description: 'github token to release to the breez-liquid-sdk-flutter repository' required: true jobs: build-tag-release: runs-on: ubuntu-latest steps: - name: Checkout breez-liquid-sdk-flutter repo uses: actions/checkout@v3 with: repository: breez/breez-liquid-sdk-flutter ssh-key: ${{ secrets.REPO_SSH_KEY }} fetch-depth: 0 path: dist - name: Checkout breez-liquid-sdk repo uses: actions/checkout@v3 with: repository: ${{ inputs.repository || github.repository }} ref: ${{ inputs.ref || github.sha }} path: build - uses: subosito/flutter-action@v2 with: channel: 'stable' - name: Copy package files working-directory: dist run: | rm -rf android rm -rf ios rm -rf lib cp -r ../build/packages/flutter/android . cp -r ../build/packages/flutter/ios . cp -r ../build/packages/flutter/lib . cp -r ../build/lib/bindings/langs/flutter/breez_liquid_sdk/include/breez_liquid_sdk.h ios/Classes cp ../build/packages/flutter/analysis_options.yaml . cp ../build/packages/flutter/pubspec.yaml . cp ../build/packages/flutter/pubspec_overrides.yaml . - name: Copy docs working-directory: dist run: | cp ../build/packages/flutter/CHANGELOG.md . || true cp ../build/packages/flutter/LICENSE . || true cp ../build/packages/flutter/README.md . || true - uses: actions/download-artifact@v3 with: name: bindings-flutter path: bindings/ - name: Set package version working-directory: dist run: | sed -i.bak -e 's/version:.*/version: ${{ inputs.package-version }}/' pubspec.yaml sed -i.bak -e 's/path:.*/git:\n url: git@github.com:breez\/breez-liquid-sdk-dart.git\n ref: ${{ inputs.package-version }}/' pubspec_overrides.yaml sed -i.bak -e "s/^version .*/version '${{ inputs.package-version }}'/" android/build.gradle sed -i.bak -e 's/set(TagName.*/set(TagName "v${{ inputs.package-version }}")/' android/CMakeLists.txt sed -i.bak -e "s/^version = .*/version = '${{ inputs.package-version }}'/" ios/flutter_breez_liquid.podspec rm pubspec.yaml.bak rm pubspec_overrides.yaml.bak rm android/build.gradle.bak rm android/CMakeLists.txt.bak rm ios/flutter_breez_liquid.podspec.bak - name: Archive flutter release uses: actions/upload-artifact@v3 with: name: breez-liquid-sdk-flutter-${{ inputs.package-version || github.sha }} path: | dist/* !dist/.git - name: Tag the Flutter package working-directory: dist if: ${{ inputs.publish }} run: | git config --global user.email github-actions@github.com git config --global user.name github-actions git add . git commit -m "Update Flutter package to version v${{ inputs.package-version }}" git push git tag v${{ inputs.package-version }} -m "v${{ inputs.package-version }}" git push --tags - name: Release and attach binary artifacts if: ${{ inputs.publish }} uses: softprops/action-gh-release@v2 with: repository: breez/breez-liquid-sdk-flutter files: | bindings/android.tar.gz bindings/breez_liquid_sdk.xcframework.zip bindings/other.tar.gz tag_name: v${{ inputs.package-version || '0.0.1' }} generate_release_notes: false token: ${{ secrets.SWIFT_RELEASE_TOKEN }} prerelease: true