Skip to content
Merged
Changes from all commits
Commits
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
164 changes: 78 additions & 86 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
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@v2
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Create artifacts directory
run: mkdir artifacts

- name: Build Changelog
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v3
Expand All @@ -29,126 +33,114 @@ jobs:

- 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}"

echo "${messageWithoutDoubleQuotes}" > artifacts/slack-changelog

- name: Setup app version
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "${messageWithoutDoubleQuotes}" > slack-changelog

- name: Create GitHub release
id: release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.RELEASE_VERSION }}
release_name: ${{ env.RELEASE_VERSION }}
body: ${{ steps.build_changelog.outputs.changelog }}

- name: Save release upload URL and version number to artifact
run: |
echo "${{ steps.release.outputs.upload_url }}" > artifacts/release-upload-url
echo "${{ env.RELEASE_VERSION }}" > artifacts/release-version

- name: Upload artifacts
uses: actions/upload-artifact@v1
set -euo pipefail
PRERELEASE_FLAG=""
if [[ "${{ env.RELEASE_VERSION }}" == *"-alpha."* ]] || [[ "${{ env.RELEASE_VERSION }}" == *"-beta."* ]]; then
PRERELEASE_FLAG="--prerelease"
fi
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 }}" \
$PRERELEASE_FLAG

- name: Upload metadata artifact
uses: actions/upload-artifact@v4
with:
name: artifacts
path: artifacts
name: metadata
path: slack-changelog


build-release:
name: build-release
needs: ['create-release']
needs: [create-release]
runs-on: ubuntu-latest
container: thyrlian/android-sdk:latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Get create-release artifacts
uses: actions/download-artifact@v1
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
name: artifacts
path: artifacts
java-version: '11'
distribution: 'temurin'
cache: gradle

- name: Read artifacts
shell: bash
run: |
# Set the release_upload_url
release_upload_url="$(cat artifacts/release-upload-url)"
echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV
echo "release upload url: $RELEASE_UPLOAD_URL"

# Set the release_version
release_version="$(cat artifacts/release-version)"
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
echo "release version: $RELEASE_VERSION"

# Set the slack-changelog
slack_changelog=$(cat artifacts/slack-changelog)
echo "SLACK_CHANGELOG=$slack_changelog" >> $GITHUB_ENV
echo "slack changelog: $SLACK_CHANGELOG"

# Install dependencies and setup keystore
- name: Setup environment
shell: bash
- name: Setup keystore
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
run: |
apt-get update && apt-get install -y file make
echo "$KEYSTORE_BASE64" | base64 -d > SimpleLogin/simplelogin.keystore
run: echo "$KEYSTORE_BASE64" | base64 -d > app/simplelogin.keystore

- name: Build application
shell: bash
env:
KEYSTORE_KEY_ALIAS: ${{ secrets.KEYSTORE_KEY_ALIAS }}
KEYSTORE_KEY_PASSWORD: ${{ secrets.KEYSTORE_KEY_PASSWORD }}
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
run: |
pushd SimpleLogin/
./gradlew assembleRelease
popd

run: ./gradlew assembleRelease

- name: Prepare uploads
shell: bash
- name: Prepare APKs
run: |
echo "PLAYSTORE_ASSET_NAME=simplelogin-playstore-${RELEASE_VERSION}.apk" >> $GITHUB_ENV
echo "PLAYSTORE_ASSET_PATH=SimpleLogin/app/build/outputs/apk/playstore/release/app-playstore-release.apk" >> $GITHUB_ENV

echo "FDROID_ASSET_NAME=simplelogin-fdroid-${RELEASE_VERSION}.apk" >> $GITHUB_ENV
echo "FDROID_ASSET_PATH=SimpleLogin/app/build/outputs/apk/fdroid/release/app-fdroid-release.apk" >> $GITHUB_ENV

- name: Upload release archive (Playstore)
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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:
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
asset_path: ${{ env.PLAYSTORE_ASSET_PATH }}
asset_name: ${{ env.PLAYSTORE_ASSET_NAME }}
asset_content_type: application/octet-stream
name: apks
path: apks

- name: Upload release archive (FDroid)
uses: actions/upload-release-asset@v1.0.1
- name: Download metadata
uses: actions/download-artifact@v4
with:
name: metadata
path: metadata

- name: Upload APKs to release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
asset_path: ${{ env.FDROID_ASSET_PATH }}
asset_name: ${{ env.FDROID_ASSET_NAME }}
asset_content_type: application/octet-stream
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
Expand Down
Loading