|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: push |
| 4 | + |
| 5 | +concurrency: |
| 6 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 7 | + cancel-in-progress: true |
| 8 | + |
| 9 | +jobs: |
| 10 | + lint: |
| 11 | + name: Lint |
| 12 | + runs-on: ubuntu-latest |
| 13 | + timeout-minutes: 10 |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v3 |
| 16 | + |
| 17 | + - name: Setup |
| 18 | + uses: ./.github/actions/setup |
| 19 | + with: |
| 20 | + google_services: ${{ secrets.GOOGLE_SERVICES }} |
| 21 | + |
| 22 | + - name: Run lint |
| 23 | + run: ./gradlew lint |
| 24 | + |
| 25 | + test: |
| 26 | + name: Test |
| 27 | + runs-on: ubuntu-latest |
| 28 | + timeout-minutes: 10 |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v3 |
| 31 | + |
| 32 | + - name: Setup |
| 33 | + uses: ./.github/actions/setup |
| 34 | + with: |
| 35 | + google_services: ${{ secrets.GOOGLE_SERVICES }} |
| 36 | + |
| 37 | + - name: Run test |
| 38 | + run: ./gradlew test |
| 39 | + |
| 40 | + build: |
| 41 | + name: Build |
| 42 | + runs-on: ubuntu-latest |
| 43 | + timeout-minutes: 10 |
| 44 | + needs: [ lint, test ] |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v3 |
| 47 | + |
| 48 | + - name: Setup |
| 49 | + uses: ./.github/actions/setup |
| 50 | + with: |
| 51 | + google_services: ${{ secrets.GOOGLE_SERVICES }} |
| 52 | + |
| 53 | + - name: Build release |
| 54 | + run: ./gradlew clean assembleRelease --stacktrace |
| 55 | + |
| 56 | + distribute: |
| 57 | + if: startsWith(github.ref_name, 'release/') |
| 58 | + name: Distribute |
| 59 | + runs-on: ubuntu-latest |
| 60 | + timeout-minutes: 10 |
| 61 | + needs: build |
| 62 | + steps: |
| 63 | + - uses: actions/checkout@v3 |
| 64 | + |
| 65 | + - name: Setup |
| 66 | + uses: ./.github/actions/setup |
| 67 | + with: |
| 68 | + google_services: ${{ secrets.GOOGLE_SERVICES }} |
| 69 | + |
| 70 | + - name: Put files |
| 71 | + env: |
| 72 | + KEYSTORE: ${{ secrets.KEYSTORE }} |
| 73 | + SIGNING: ${{ secrets.SIGNING }} |
| 74 | + APP_DISTRIBUTION: ${{ secrets.APP_DISTRIBUTION }} |
| 75 | + run: | |
| 76 | + echo "Adding files" |
| 77 | + TMP_SECRETS_PATH=secrets |
| 78 | + mkdir ${TMP_SECRETS_PATH} |
| 79 | + echo $KEYSTORE | base64 -d > "${TMP_SECRETS_PATH}"/portto.jjs |
| 80 | + echo $SIGNING | base64 -d > "${TMP_SECRETS_PATH}"/signing.properties |
| 81 | + echo $APP_DISTRIBUTION | base64 -d > "${TMP_SECRETS_PATH}"/app-distribution.json |
| 82 | + echo "All files Added ✅" |
| 83 | +
|
| 84 | + - name: Fill Infura id |
| 85 | + run: sed -i 's/INFURA_ID.*/INFURA_ID = \"${{ secrets.INFURA_ID }}\"/' app/src/main/java/com/portto/valuedapp/Config.kt |
| 86 | + |
| 87 | + - name: Distribute sample app |
| 88 | + run: bash ./scripts/distribute.sh |
| 89 | + |
| 90 | + publish: |
| 91 | + if: github.ref_name == 'main' |
| 92 | + name: Publish |
| 93 | + runs-on: ubuntu-latest |
| 94 | + timeout-minutes: 10 |
| 95 | + needs: build |
| 96 | + steps: |
| 97 | + - uses: actions/checkout@v3 |
| 98 | + |
| 99 | + - name: Setup |
| 100 | + uses: ./.github/actions/setup |
| 101 | + with: |
| 102 | + google_services: ${{ secrets.GOOGLE_SERVICES }} |
| 103 | + |
| 104 | + - name: Publish library |
| 105 | + env: |
| 106 | + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY }} |
| 107 | + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PASSWORD }} |
| 108 | + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }} |
| 109 | + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} |
| 110 | + run: bash ./scripts/publish.sh |
| 111 | + |
| 112 | + - name: Get version |
| 113 | + run: | |
| 114 | + echo "version=$(grep "versionName" dependencies.gradle | awk -F: '{print $2}' | tr -d ' '\',)" >> $GITHUB_ENV |
| 115 | +
|
| 116 | + - name: Create and push tag |
| 117 | + run: | |
| 118 | + git config user.name "GitHub Actions" |
| 119 | + git config user.email noreply@github.com |
| 120 | + git tag -a ${{ env.version }} -m "Release v${{ env.version }}" |
| 121 | + git push origin ${{ env.version }} |
| 122 | +
|
| 123 | + - name: Create release |
| 124 | + uses: softprops/action-gh-release@v1 |
| 125 | + with: |
| 126 | + name: v${{ env.version }} |
| 127 | + tag_name: ${{ env.version }} |
| 128 | + draft: false |
| 129 | + prerelease: false |
| 130 | + |
| 131 | + - name: Create pull request (main -> develop) |
| 132 | + run: > |
| 133 | + gh pr create |
| 134 | + --base develop |
| 135 | + --head main |
| 136 | + --title '[${{ env.version }}] Merge main into develop' |
| 137 | + --body 'Created by Github Actions' |
| 138 | + --reviewer Doge-is-Dope,kihonyoo,imjacklai |
| 139 | + env: |
| 140 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments