Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate release process to Maven Central and Gradle Plugin Portal #1663

Merged
merged 39 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
09124a1
Update to Swig 4.2.0
rorbech Feb 22, 2024
b11f2e4
Clean up build-android-package node before building
rorbech Feb 22, 2024
4bb0c0c
GHA adding dependency for iOS test
nhachicha Feb 22, 2024
10cc4aa
Merge remote-tracking branch 'origin/cr/swig-4.2.0'
nhachicha Feb 22, 2024
f58b79e
test release (staging to Sonatype)
nhachicha Feb 22, 2024
d957d08
Install dep for realpath
nhachicha Feb 22, 2024
45b8986
fix
nhachicha Feb 22, 2024
15fe2d5
test
nhachicha Feb 23, 2024
3ec50d4
Passing argument properly
nhachicha Feb 23, 2024
c2ba602
Publish only the artifacts
nhachicha Feb 27, 2024
a19392f
Merge remote-tracking branch 'origin/main' into nh/GHA/release
nhachicha Feb 27, 2024
ee61cd3
Testing release
nhachicha Feb 27, 2024
be39ffa
Debugging
nhachicha Feb 27, 2024
1af080f
Fix IOCTL
nhachicha Feb 27, 2024
24c8b58
debug
nhachicha Feb 28, 2024
5bdc1f5
debug
nhachicha Feb 28, 2024
878a302
fix script
nhachicha Feb 28, 2024
338356a
debug
nhachicha Feb 28, 2024
ad4edd4
disable steps
nhachicha Feb 28, 2024
a94d06b
debug
nhachicha Mar 2, 2024
0ffc79c
debug
nhachicha Mar 2, 2024
9dd9f90
debug
nhachicha Mar 2, 2024
1f7e8a2
debug
nhachicha Mar 2, 2024
76a7e92
Merge remote-tracking branch 'origin/main' into nh/GHA/release
nhachicha Mar 6, 2024
e3020fc
Debugging vars
nhachicha Mar 6, 2024
c62402e
syntax
nhachicha Mar 6, 2024
fdf6357
syntax
nhachicha Mar 6, 2024
b628d3d
clean up
nhachicha Mar 7, 2024
de4081b
Conditional trigger for release
nhachicha Mar 7, 2024
af88825
Missed var
nhachicha Mar 7, 2024
3520357
Fallback in case no tag is found
nhachicha Mar 7, 2024
29ba516
fixes
nhachicha Mar 7, 2024
64d7444
fixes
nhachicha Mar 7, 2024
48d0da5
Fixes
nhachicha Mar 7, 2024
4010740
un-comment steps
nhachicha Mar 7, 2024
d56884d
re-enable publishing
nhachicha Mar 7, 2024
852befd
more cleanup
nhachicha Mar 7, 2024
60ef040
Changelog
nhachicha Mar 8, 2024
dd00b06
Merge remote-tracking branch 'origin/main' into nh/GHA/release
nhachicha Mar 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions .github/workflows/include-deploy-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Deploy release

on:
workflow_call:
inputs:
version-label:
required: true
type: string

packages-sha-label:
required: true
type: string

jobs:
deploy:
runs-on: macos-latest
name: Deploy release

steps:
- name: git checkout
uses: actions/checkout@v3
with:
submodules: "recursive"

- name: Setup Java 11
uses: actions/setup-java@v3
with:
distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }}
java-version: ${{ vars.VERSION_JAVA }}

- name: Setup Gradle and task/dependency caching
uses: gradle/gradle-build-action@v2
with:
cache-read-only: false

- name: Setup cmake
uses: jwlawson/[email protected]
with:
cmake-version: ${{ vars.VERSION_CMAKE }}

- name: Setup ninja
uses: cmelchior/setup-ninja@master
with:
version: ${{ vars.VERSION_NINJA }}

- name: Install ccache
uses: hendrikmuhs/[email protected]
with:
key: 'jvm-package'
max-size: '2.0G'

- name: Install coreutils and s3cmd
run: brew install coreutils s3cmd

- name: Prepend ccache executables to the PATH
run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH

# See https://github.com/hendrikmuhs/ccache-action/issues/94
- name: Configure ccache
run: |
ccache --set-config="compiler_check=content"
ccache --show-config
echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang
echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++
# TODO This matches 23.2.8568313, but what happens if we define specific ndk version in our build?
- name: Setup NDK
uses: nttld/setup-ndk@v1
with:
ndk-version: r23c

# We cannot use artifacts as they cannot be shared between workflows, so use cache instead.
- name: Setup build cache
uses: actions/cache@v3
with:
path: ./packages/build/m2-buildrepo
key: packages-m2-jvm-sync-${{ inputs.packages-sha-label }}

- name: Restore Linux JNI lib
uses: actions/download-artifact@v3
with:
name: jni-linux-lib-${{ inputs.version-label }}
path: ./packages/cinterop/build/realmLinuxBuild

- name: Restore Windows JNI lib
uses: actions/download-artifact@v3
with:
name: jni-windows-lib-${{ inputs.version-label }}
path: ./packages/cinterop/build/realmWindowsBuild/Release

- name: Restore MacOS JNI lib
uses: actions/download-artifact@v3
with:
name: jni-macos-lib-${{ inputs.version-label }}
path: ./packages/cinterop/build/realmMacOsBuild

- name: Restore m2-buildrepo
uses: actions/download-artifact@v3
with:
name: all-packages-${{ inputs.version-label }}
path: ./packages/build/m2-buildrepo

- name: Publish release to Maven Central
run: |
set +x
sh ./tools/publish_release.sh "${{ secrets.MAVEN_CENTRAL_USER_DBG }}" "${{ secrets.MAVEN_CENTRAL_KEY_DBG }}" \
"${{ secrets.AWS_S3_ACCESS_KEY_ID }}" "${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}" \
"${{ secrets.DOCS_S3_ACCESS_KEY }}" "${{ secrets.DOCS_S3_SECRET_KEY }}" \
"${{ secrets.SLACK_URL_RELEASE }}" "${{ secrets.SLACK_URL_CI }}" \
"${{ secrets.GRADLE_PORTAL_KEY }}" "${{ secrets.GRADLE_PORTAL_SECRET }}" \
'-PsignBuild=true -PsignSecretRingFileKotlin="${{ secrets.GPG_SIGNING_KEY_BASE_64_DBG }}" -PsignPasswordKotlin=${{ secrets.GPG_PASS_PHRASE_DBG }}'
74 changes: 70 additions & 4 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ jobs:
runs-on: macos-latest
needs: [check-cache, build-jni-swig-stub]
if: |
always() &&
!cancelled() &&
!contains(needs.*.result, 'failure') &&
always() &&
!cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.check-cache.outputs.jni-windows-lib-cache-hit != 'true'

Expand Down Expand Up @@ -1642,4 +1642,70 @@ jobs:

secrets: inherit
with:
version-label: ${{ needs.check-cache.outputs.version-label }}
version-label: ${{ needs.check-cache.outputs.version-label }}

# This job sets an output `is_publish_build` to `true` if this is a release build
check-release-build:
runs-on: ubuntu-latest
needs: [check-cache]
outputs:
is_publish_build: ${{ steps.check_release.outputs.is_publish_build }}

steps:
- uses: actions/checkout@v3

- name: Get Git tag
run: |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the tag does not exist the tag would be "NONE", shouldn't we stop the release if not gittag is defined?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the gittag is NONE is_publish_build will be false in the next step which will skip the release
image

gitTag=$(git describe --tags --exact-match HEAD) || echo "NONE"
echo "Git branch/tag: ${GITHUB_REF}/${gitTag:-'none'}"

- name: Check if release build
id: check_release
run: |
if [[ -z "$gitTag" ]]; then
gitSha=$(git rev-parse HEAD | cut -c1-8)
echo "Building commit: ${{ needs.check-cache.outputs.version-label }} - ${gitSha}"
echo "is_publish_build=false" >> $GITHUB_OUTPUT
else
if [[ "$gitTag" != "v${{ needs.check-cache.outputs.version-label }}" ]]; then
echo "Git tag '${gitTag}' does not match v${{ needs.check-cache.outputs.version-label }}"
echo "is_publish_build=false" >> $GITHUB_OUTPUT
else
echo "Building release: '${gitTag}'"
echo "is_publish_build=true" >> $GITHUB_OUTPUT
fi
fi


- name: Print is release build
run: |
echo "Is release build: ${{ steps.check_release.outputs.is_publish_build }}"

deploy-release:
uses: ./.github/workflows/include-deploy-release.yml
needs: [
check-cache,
check-release-build,
static-analysis,
integration-tests,
test-jvm-packages,
test-macos-packages,
test-ios-packages,
test-android-packages-emulator,
# test-android-packages-device-farm,
test-android-packages-device-farm-sync,
package-all-artifacts
]
if: |
always() &&
!cancelled() &&
!endsWith(needs.check-cache.outputs.version-label, '-SNAPSHOT') &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
(github.ref == 'refs/heads/main' || github.ref == 'refs/heads/releases') &&
(needs.check-release-build.outputs.is_publish_build == 'true')

secrets: inherit
with:
version-label: ${{ needs.check-cache.outputs.version-label }}
packages-sha-label: ${{ needs.check-cache.outputs.packages-sha }}
Loading