diff --git a/build.sh b/.build/release.sh similarity index 78% rename from build.sh rename to .build/release.sh index f79c691..128c881 100755 --- a/build.sh +++ b/.build/release.sh @@ -20,8 +20,6 @@ function create_changelogs_if_not_present() { create_changelog_if_not_present ${version_code} "en-US" create_changelog_if_not_present ${version_code} "nl-NL" local changelog_path="fastlane/metadata/android/*/changelogs" - # travis_add_and_commit "$changelog_path" "chore: Added default changelogs for version code ${version_code}." - # travis_push "$TRAVIS_BRANCH" } function get_version_code_from_gradle() { @@ -35,11 +33,10 @@ function get_version_number_from_gradle() { function tag_git_with_version_number() { local version_number="$1" - if [[ "$version_number" != "" ]]; then + if [[ -n "$version_number" ]]; then echo "Tagging version $version_number" git tag -a "$version_number" -m"Version $version_number [ci skip]" - # travis_push $TRAVIS_BRANCH - travis_push "$version_number" + git push "$version_number" else >&2 echo "Version number not tagged!" fi @@ -50,12 +47,24 @@ set -ex basedir=$(dirname $0) source $basedir/build-helpers.sh -# travis_checkout_branch version_code=$(get_version_code_from_gradle) version_number=$(get_version_number_from_gradle) + +# Create changelogs create_changelogs_if_not_present ${version_code} + +# Decrypt and unpack secrets +gpg --quiet --batch --yes --decrypt --passphrase="$SECRETS_FILE_PASSPHRASE" \ + --output secrets.tar secrets.tar.gpg +tar xvf secrets.tar + +# Create release ./gradlew clean bundleRelease -if [[ "${TRAVIS_BRANCH}" == "master" ]]; then - bundle exec fastlane deploy version_code:${version_code} - tag_git_with_version_number ${version_number} -fi + +# Upload to Google Play +# TODO +# bundle exec fastlane deploy version_code:${version_code} + +# Create a Git tag +# TODO +# tag_git_with_version_number ${version_number} diff --git a/build-helpers.sh b/.build/travis-utils.sh similarity index 100% rename from build-helpers.sh rename to .build/travis-utils.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..d871128 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,29 @@ +name: Main +on: [push] +jobs: + compile-test-package: + name: Compile, test, package + runs-on: ubuntu-20.04 + steps: + - name: Clone repository + uses: actions/checkout@v2 + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: "1.8" + - name: Compile, test and package + run: ./gradlew clean compile test bundleRelease + release: + name: Release + runs-on: ubuntu-20.04 + needs: compile-test-package + if: ${{ github.ref == 'refs/heads/master' }} + steps: + - uses: actions/setup-ruby@v1 + with: + ruby-version: "2.7" + bundler-cache: true + - name: Create a release + run: .build/release.sh + env: + SECRETS_FILE_PASSPHRASE: ${{ secrets.SECRETS_FILE_PASSPHRASE }} diff --git a/.travis.yml b/.travis.yml.bak similarity index 100% rename from .travis.yml rename to .travis.yml.bak diff --git a/dev.md b/dev.md index cc00686..4c381fb 100644 --- a/dev.md +++ b/dev.md @@ -1,6 +1,35 @@ # Documentation -## Signing and Deploying +TODO: See +https://www.raywenderlich.com/19407406-continuous-delivery-for-android-using-github-actions +TODO: Search for "TODO" in the entire repository +TODO: Delete secrets.tar.enc + + +## Signing and Deploying (GitHub Actions) + +<-- Reference: https://docs.github.com/en/actions/reference/encrypted-secrets#limits-for-secrets --> + +1. Create the signing key: + ```sh + keytool -genkey -v -keystore scheleaap.jks -alias wmsnotes -keyalg RSA -keysize 2048 -validity 10000 + ``` +1. Create a file containing all secrets: + ```sh + tar cvf secrets.tar scheleaap.jks keystore.properties google-services.json + travis login --com + travis encrypt-file --com --add secrets.tar + ``` +1. Encrypt the secrets file: + ```sh + gpg --symmetric --cipher-algo AES256 secrets.tar + ``` + You will be asked to enter a passphrase. +1. [Create a repository secret](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository) named `SECRETS_FILE_PASSPHRASE` containing the passphrase. + + +## Singing and Deploying (Travis CI) + The Travis CLI was installed as follows (on Ubuntu 16.04): ```sh