Skip to content

Commit

Permalink
Setup prerelease for android package
Browse files Browse the repository at this point in the history
  • Loading branch information
georgeblahblah committed Feb 15, 2024
1 parent b88d2fb commit 6e9a96b
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 52 deletions.
107 changes: 64 additions & 43 deletions .github/actions/generate-native-package/native.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/bash

# Read arguments
export ACCESS_TOKEN=$1
# export ACCESS_TOKEN=$1
# TODO: remove fake access token
export ACCESS_TOKEN=fake
export PLATFORM=$2
export RELEASE_TYPE=$3

Expand Down Expand Up @@ -29,54 +31,73 @@ cd ../
echo "" >> bridget/thrift/native.thrift
echo "const string BRIDGET_VERSION = \"$CURRENT_VERSION\"" >> bridget/thrift/native.thrift

echo "would release $RELEASE_TYPE with version $CURRENT_VERSION"
exit 0
# # Platform tasks
# if [ "$PLATFORM" == "ios" ]; then
echo "Releasing $RELEASE_TYPE to platform $PLATFORM with version $CURRENT_VERSION"
# Platform tasks
if [ "$PLATFORM" == "ios" ]; then

# # Check out the Swift repo and delete all existing source files
# git clone https://github.com/guardian/bridget-swift.git
# rm -rf bridget-swift/Sources/Bridget
# mkdir -p bridget-swift/Sources/Bridget
# Check out the Swift repo and delete all existing source files
git clone https://github.com/guardian/bridget-swift.git
if [ "$RELEASE_TYPE" = "prerelease" ];
then
git checkout -b $CURRENT_VERSION
fi
rm -rf bridget-swift/Sources/Bridget
mkdir -p bridget-swift/Sources/Bridget

# thrift --gen swift:async_servers -r -out bridget-swift/Sources/Bridget bridget/thrift/native.thrift
thrift --gen swift:async_servers -r -out bridget-swift/Sources/Bridget bridget/thrift/native.thrift

# # Commit changes
# cd bridget-swift
# if [[ -n `git diff` ]]; then
# git add Sources/Bridget/*.swift
# git commit -m "Update Swift models $CURRENT_VERSION"
# git tag $CURRENT_VERSION
# git push origin main
# git push --tags
# fi
# elif [ "$PLATFORM" == "android" ]; then
# Commit changes
cd bridget-swift
if [[ -n `git diff` ]]; then
git add Sources/Bridget/*.swift
git commit -m "Update Swift models $CURRENT_VERSION"
git tag $CURRENT_VERSION
if [ "$RELEASE_TYPE" = "prerelease" ];
then
echo "git push -u origin $CURRENT_VERSION"
# git push -u origin $CURRENT_VERSION
else
echo "git push origin main"
# git push origin main
fi
# git push --tags
echo "git push --tags"
fi
elif [ "$PLATFORM" == "android" ]; then

# # Check out the bridget-android repo and delete all existing source files
# git clone https://github.com/guardian/bridget-android.git
# rm -rf bridget-android/library/src/main
# Check out the bridget-android repo and delete all existing source files
git clone https://github.com/guardian/bridget-android.git
rm -rf bridget-android/library/src/main

# # Create fresh directories
# mkdir -p bridget-android/library/src/main/thrift
# mkdir -p bridget-android/library/src/main/java
# Create fresh directories
mkdir -p bridget-android/library/src/main/thrift
mkdir -p bridget-android/library/src/main/java


# # Prefix package name in thrift file and copy it to the bridget-android repo
# cat <(echo -e "namespace java com.theguardian.bridget.thrift\n") native.thrift > native_temp.thrift && mv native_temp.thrift native.thrift
# cp bridget/thrift/native.thrift bridget-android/library/src/main/thrift
# Prefix package name in thrift file and copy it to the bridget-android repo
cat <(echo -e "namespace java com.theguardian.bridget.thrift\n") native.thrift > native_temp.thrift && mv native_temp.thrift native.thrift
cp bridget/thrift/native.thrift bridget-android/library/src/main/thrift

# # Generate thrift classes
# thrift -gen java:generated_annotations=undated -out library/src/main/java/ library/src/main/thrift/native.thrift
# Generate thrift classes
thrift -gen java:generated_annotations=undated -out library/src/main/java/ library/src/main/thrift/native.thrift

# # Commit changes and tag the current version
# cd bridget-android
# if [[ -n `git diff` ]]; then
# git add bridget-android/library/src/main/*
# git commit -m "Update Thrift generated classes $CURRENT_VERSION"
# git tag $CURRENT_VERSION
# git push origin main
# git push --tags
# fi
# else
# echo "Unrecognised platform. Please specify \"ios\" or \"android\" as the second argument"
# fi
# Commit changes and tag the current version
cd bridget-android
if [[ -n `git diff` ]]; then
git add bridget-android/library/src/main/*
git commit -m "Update Thrift generated classes $CURRENT_VERSION"
git tag $CURRENT_VERSION
if [ "$RELEASE_TYPE" = "prerelease" ];
then
echo "git push -u origin $CURRENT_VERSION"
# git push -u origin $CURRENT_VERSION
else
echo "git push origin main"
# git push origin main
fi
# git push --tags
echo "git push --tags"
fi
else
echo "Unrecognised platform. Please specify \"ios\" or \"android\" as the second argument"
fi
18 changes: 9 additions & 9 deletions .github/workflows/generate-prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ jobs:
platform: "ios"
release_type: "prerelease"

# generate-android-package:
# needs: bump-tag
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: ./.github/actions/generate-native-package
# with:
# access_token: ${{ secrets.ACCESS_TOKEN }}
# platform: "android"
generate-android-package:
needs: bump-tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/generate-native-package
with:
access_token: ${{ secrets.ACCESS_TOKEN }}
platform: "android"

0 comments on commit 6e9a96b

Please sign in to comment.