diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2953dbc24..855d5ea4f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,10 +2,21 @@ on: push: tags: - 'v*.*.*' + workflow_dispatch: + inputs: + alpha_version: + description: 'Alpha version' + required: true + default: '' + run-on-runner: + description: 'Specify the runner to use' + required: true + default: 'macos-11' + name: Build jobs: build: - runs-on: macos-11 + runs-on: ${{ github.event.inputs.run-on-runner }} steps: - name: fix android ndk bundle run: | @@ -58,7 +69,11 @@ jobs: run: | GIT_SUMMARY=$(git describe --tags --always) echo "FLAGS=-X github.com/anyproto/anytype-heart/util/vcs.GitSummary=${GIT_SUMMARY} -X github.com/anyproto/anytype-heart/metrics.DefaultAmplitudeKey=${AMPLITUDE_KEY} -X github.com/anyproto/anytype-heart/util/unsplash.DefaultToken=${UNSPLASH_KEY}" >> $GITHUB_ENV - echo VERSION=${GITHUB_REF##*/} >> $GITHUB_ENV + VERSION=${{ github.event.inputs.alpha_version }} + if [ -z "$VERSION" ]; then + VERSION=${GITHUB_REF##*/} + fi + echo VERSION=${VERSION} >> $GITHUB_ENV echo SDKROOT=$(xcrun --sdk macosx --show-sdk-path) >> $GITHUB_ENV echo GOPRIVATE=github.com/anyproto >> $GITHUB_ENV echo $(pwd)/deps >> $GITHUB_PATH @@ -151,8 +166,15 @@ jobs: make test-deps gomobile bind -tags "envproduction nogrpcserver gomobile nowatchdog nosigar nomutexdeadlockdetector" -ldflags "$FLAGS" -v -target=ios -o Lib.xcframework github.com/anyproto/anytype-heart/clientlibrary/service github.com/anyproto/anytype-heart/core || true sudo /usr/sbin/purge - gtar --exclude ".*" -czvf ios_framework_${VERSION}.tar.gz Lib.xcframework protobuf json - mv ios_framework_${VERSION}.tar.gz .release/ + gtar --exclude ".*" -czvf ios_framework.tar.gz Lib.xcframework protobuf json + gradle publish + mv ios_framework.tar.gz .release/ios_framework_${VERSION}.tar.gz + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_USER: ${{ github.actor }} + MAVEN_ARTIFACT_ID: 'anytype-heart-ios' + MAVEN_ARTIFACT_NAME: 'ios_framework.tar.gz' + MAVEN_ARTIFACT_VERSION: ${VERSION} - name: Make java protos run: | make protos-java @@ -181,7 +203,11 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_USER: ${{ github.actor }} + MAVEN_ARTIFACT_ID: 'anytype-heart-android' + MAVEN_ARTIFACT_NAME: 'lib.aar' + MAVEN_ARTIFACT_VERSION: ${VERSION} - name: Release + if: github.event.inputs.alpha_version == '' uses: softprops/action-gh-release@v1 with: prerelease: ${{ contains(github.ref, '-rc') }} @@ -254,7 +280,11 @@ jobs: GIT_SUMMARY=$(git describe --tags --always) echo GOPRIVATE=github.com/anyproto >> $GITHUB_ENV echo "FLAGS=-X github.com/anyproto/anytype-heart/util/vcs.GitSummary=${GIT_SUMMARY} -X github.com/anyproto/anytype-heart/metrics.DefaultAmplitudeKey=${AMPLITUDE_KEY} -X github.com/anyproto/anytype-heart/util/unsplash.DefaultToken=${UNSPLASH_KEY}" >> $GITHUB_ENV - echo VERSION=${GITHUB_REF##*/} >> $GITHUB_ENV + VERSION=${{ github.event.inputs.alpha_version }} + if [ -z "$VERSION" ]; then + VERSION=${GITHUB_REF##*/} + fi + echo VERSION=${VERSION} >> $GITHUB_ENV git config --global url."https://${{ secrets.ANYTYPE_PAT }}@github.com/".insteadOf "https://github.com/" - name: Go mod download run: | @@ -306,6 +336,7 @@ jobs: mv js_${VERSION}_${OSARCH}.tar.gz .release/ done - name: Release + if: github.event.inputs.alpha_version == '' uses: softprops/action-gh-release@v1 with: prerelease: ${{ contains(github.ref, '-rc') }} diff --git a/build.gradle b/build.gradle index bd855f9e6..759732ab8 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,15 @@ def githubProperties = new Properties() def getArtificatId = { -> - return "anytype-heart-android" + return System.getenv("MAVEN_ARTIFACT_ID") +} + +def getArtifactName = { -> + return System.getenv("MAVEN_ARTIFACT_NAME") +} + +def getArtifactVersion = { -> + return System.getenv("MAVEN_ARTIFACT_VERSION") } buildscript { @@ -26,7 +34,8 @@ publishing { bar(MavenPublication) { groupId 'io.anyproto' // Replace with group ID artifactId getArtificatId() - artifact("lib.aar") + artifact getArtifactName() + version getArtifactVersion() } }