Merge pull request #154 from simple-login/feat/update-ksp #23
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build the app | |
| on: | |
| push: | |
| tags: | |
| - '[0-9]+.[0-9]+.[0-9]+' | |
| - '[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+' | |
| - '[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+' | |
| permissions: | |
| contents: write | |
| env: | |
| RELEASE_VERSION: ${{ github.ref_name }} | |
| jobs: | |
| create-release: | |
| name: create-release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| - name: Build Changelog | |
| id: build_changelog | |
| uses: mikepenz/release-changelog-builder-action@v3 | |
| with: | |
| configuration: ".github/changelog_configuration.json" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Prepare Slack notification contents | |
| run: | | |
| set -euo pipefail | |
| changelog=$(cat << EOH | |
| ${{ steps.build_changelog.outputs.changelog }} | |
| EOH | |
| ) | |
| messageWithoutNewlines=$(echo "${changelog}" | awk '{printf "%s\\n", $0}') | |
| messageWithoutDoubleQuotes=$(echo "${messageWithoutNewlines}" | sed "s/\"/'/g") | |
| echo "${messageWithoutDoubleQuotes}" > slack-changelog | |
| - name: Create GitHub release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| if [[ "${{ env.RELEASE_VERSION }}" == *"-alpha."* ]] || [[ "${{ env.RELEASE_VERSION }}" == *"-beta."* ]]; then | |
| gh release view "${{ env.RELEASE_VERSION }}" >/dev/null 2>&1 || \ | |
| gh release create "${{ env.RELEASE_VERSION }}" \ | |
| --title "${{ env.RELEASE_VERSION }}" \ | |
| --prerelease | |
| else | |
| gh release view "${{ env.RELEASE_VERSION }}" >/dev/null 2>&1 || \ | |
| gh release create "${{ env.RELEASE_VERSION }}" \ | |
| --title "${{ env.RELEASE_VERSION }}" \ | |
| --notes "${{ steps.build_changelog.outputs.changelog }}" | |
| fi | |
| - name: Upload metadata artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: metadata | |
| path: slack-changelog | |
| build-release: | |
| name: build-release | |
| needs: [create-release] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| - name: Set up JDK 11 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '11' | |
| distribution: 'temurin' | |
| cache: gradle | |
| - name: Setup keystore | |
| env: | |
| KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }} | |
| run: echo "$KEYSTORE_BASE64" | base64 -d > app/simplelogin.keystore | |
| - name: Build application | |
| env: | |
| KEYSTORE_KEY_ALIAS: ${{ secrets.KEYSTORE_KEY_ALIAS }} | |
| KEYSTORE_KEY_PASSWORD: ${{ secrets.KEYSTORE_KEY_PASSWORD }} | |
| KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
| run: ./gradlew assembleRelease | |
| - name: Prepare APKs | |
| run: | | |
| set -euo pipefail | |
| mkdir -p apks | |
| cp app/build/outputs/apk/playstore/release/app-playstore-release.apk apks/ | |
| cp app/build/outputs/apk/fdroid/release/app-fdroid-release.apk apks/ | |
| - name: Upload APKs artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: apks | |
| path: apks/ | |
| upload-assets: | |
| name: upload-assets | |
| needs: [build-release] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download APKs | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: apks | |
| path: apks | |
| - name: Download metadata | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: metadata | |
| path: metadata | |
| - name: Upload APKs to release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| gh release upload "${{ env.RELEASE_VERSION }}" --clobber \ | |
| "apks/app-playstore-release.apk#simplelogin-playstore-${{ env.RELEASE_VERSION }}.apk" \ | |
| "apks/app-fdroid-release.apk#simplelogin-fdroid-${{ env.RELEASE_VERSION }}.apk" | |
| - name: Read Slack changelog | |
| run: | | |
| set -euo pipefail | |
| { | |
| echo 'SLACK_CHANGELOG<<EOF' | |
| cat metadata/slack-changelog | |
| echo EOF | |
| } >> "$GITHUB_ENV" | |
| - name: Post notification to Slack | |
| uses: slackapi/slack-github-action@v1.19.0 | |
| with: | |
| channel-id: ${{ secrets.SLACK_CHANNEL_ID }} | |
| payload: | | |
| { | |
| "blocks": [ | |
| { | |
| "type": "header", | |
| "text": { | |
| "type": "plain_text", | |
| "text": "New tag created on SimpleLogin Android", | |
| "emoji": true | |
| } | |
| }, | |
| { | |
| "type": "section", | |
| "text": { | |
| "type": "mrkdwn", | |
| "text": "*Tag: ${{ github.ref_name }}* (${{ github.sha }})" | |
| } | |
| }, | |
| { | |
| "type": "section", | |
| "text": { | |
| "type": "mrkdwn", | |
| "text": "*Changelog:*\n${{ env.SLACK_CHANGELOG }}" | |
| } | |
| } | |
| ] | |
| } | |
| env: | |
| SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} |