Prepare Release 0.1.2 #50
Workflow file for this run
This file contains 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: Check PR | |
on: | |
pull_request: | |
branches: | |
- master | |
- "hotfix/[0-9]+.[0-9]+.[0-9]+" | |
env: | |
FORK: "${{ github.event.pull_request.head.repo.full_name != github.repository }}" | |
APP_BUILD_TYPE: Release | |
RELEASE_CANDIDATE: "${{ github.event.pull_request.head.repo.full_name == github.repository && startsWith(github.head_ref, 'release/') }}" | |
BUNDLE_WITHOUT: development | |
FASTLANE_SKIP_UPDATE_CHECK: true | |
# Here I use some workarounds to prevent check stuck at 'waiting status update' | |
jobs: | |
# Buildin 'paths-ignore' not working here. I need to pass all checks on PR. Without it PR will stuck on 'waiting for status' | |
filter_paths: | |
name: Filter changed paths | |
runs-on: ubuntu-latest | |
outputs: | |
is_release: ${{ env.RELEASE_CANDIDATE }} | |
src_changed: ${{ steps.check_files.outputs.src_files }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dorny/[email protected] | |
id: check_files | |
with: | |
filters: | | |
src_files: | |
- '.bundle/**' | |
- '.github/workflows/*.yml' | |
- 'app/**' | |
- 'buildSrc/**' | |
- 'common/**' | |
- 'data/**' | |
- 'fastlane/actions/*.rb' | |
- 'fastlane/Appfile' | |
- 'fastlane/Fastfile' | |
- 'gradle/**' | |
- 'logic/**' | |
- 'native' | |
- '.tool-versions' | |
- '*.gradle.kts' | |
- 'Gemfile*' | |
- 'gradle*' | |
- 'rust-toolchain' | |
- '*.properties' | |
# Bump app version and commit changes | |
# WARNING: it will checkout HEAD, not BASE | |
bump_version: | |
name: PR bump version | |
runs-on: ubuntu-latest | |
if: ${{ needs.filter_paths.outputs.src_changed == 'true' || needs.filter_paths.outputs.is_release == 'true' }} | |
needs: filter_paths | |
outputs: | |
bumped: ${{ steps.persist_version.outputs.changes_detected || 'false' }} | |
version_name: ${{ steps.bump_version.outputs.VERSION_NAME }} | |
version_code: ${{ steps.bump_version.outputs.VERSION_CODE }} | |
permissions: | |
# Required by stefanzweifel/git-auto-commit-action | |
# Give the default GITHUB_TOKEN write permission to commit and push the changed files back to the repository. | |
# I can't use expressions here :( | |
contents: 'write' | |
steps: | |
- uses: actions/checkout@v4 | |
if: ${{ env.RELEASE_CANDIDATE == 'true' }} | |
with: | |
# Required by stefanzweifel/git-auto-commit-action | |
# PR check will stuck on 'waiting for status' without PAT after version bump pushing | |
token: ${{ secrets.PAT }} | |
ref: ${{ github.head_ref }} | |
- uses: actions/checkout@v4 | |
if: ${{ env.RELEASE_CANDIDATE == 'false' }} | |
- name: Setup required Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
- uses: benjlevesque/[email protected] | |
id: short-sha | |
with: | |
length: 7 | |
# Valid names for release candidate: release/0.1.0, hotfix/0.1.0. Otherwise you can use any branch name. | |
# App version name and version code depends on GH releases on BASE branch. | |
# Output app name will be different from persisted release candidate app name. | |
# Related Java properties file will be changed only if it is a release candidate | |
# Step outputs: versionName and versionCode | |
- name: Calculate version name and code | |
id: bump_version | |
run: | | |
version_tag="0.0.0" | |
# If this is a release candidate than branch should have valid name e.g. release/0.1.0 | |
if [[ ${RELEASE_CANDIDATE} = true ]]; then | |
if [[ ${{ github.head_ref }} =~ /(([0-9]+\.?){3})$ ]]; then | |
version_tag=$(echo ${BASH_REMATCH[1]}) | |
else | |
echo "Invalid branch name. It should contains version name" | |
exit 1 | |
fi | |
fi | |
o=($(bundle exec fastlane run release_version_calc token:"${{ secrets.GITHUB_TOKEN }}" tag:"v${version_tag}")) | |
name="pr-${{ github.event.number }}-${{ steps.short-sha.outputs.sha }}" | |
code=$((${o[-1]})) | |
echo "Output app name: $name, code: $code" | |
if [[ ${RELEASE_CANDIDATE} = true ]]; then | |
name_to_persist=${o[-2]} | |
bundle exec fastlane run persist_version version_name:"${name_to_persist}" version_code:"${code}" | |
fi | |
echo "VERSION_NAME=${name}" >> "$GITHUB_OUTPUT" | |
echo "VERSION_CODE=${code}" >> "$GITHUB_OUTPUT" | |
# Commit and push version change if it us a release candidate | |
- name: Persist version | |
id: persist_version | |
if: ${{ env.RELEASE_CANDIDATE == 'true' }} | |
uses: stefanzweifel/[email protected] | |
with: | |
commit_message: Bump version | |
commit_user_name: github-actions[bot] | |
commit_user_email: github-actions[bot]@users.noreply.github.com | |
file_pattern: seeneva.properties | |
# If version was changed, send a comment about it | |
- name: Send comment | |
if: steps.persist_version.outputs.changes_detected == 'true' | |
run: | | |
msg=":exclamation: App version was changed.\n\n**versionName**: ${{ steps.bump_version.outputs.VERSION_NAME }}\n**versionCode**: ${{ steps.bump_version.outputs.VERSION_CODE }}" | |
bundle exec fastlane run issue_comment token:"${{ secrets.GITHUB_TOKEN }}" number:${{ github.event.number }} msg:"$(printf "${msg}")" | |
test: | |
name: PR test | |
runs-on: ubuntu-latest | |
# This condition required to prevent multiple PR status checks after version bump was pushed | |
if: ${{ needs.bump_version.outputs.bumped == 'false' }} | |
needs: bump_version | |
steps: | |
- name: Install packages | |
run: sudo apt install autopoint | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Setup asdf | |
uses: asdf-vm/actions/[email protected] | |
- name: Install asdf plugins | |
uses: asdf-vm/actions/[email protected] | |
- name: Setup required Java | |
run: | | |
asdf install java && | |
echo "JAVA_HOME=$(asdf where java)" >> "$GITHUB_ENV" | |
- name: Setup required Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
- name: Cache Gradle wrapper | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Validate Gradle Wrapper | |
uses: gradle/wrapper-validation-action@v1 | |
- name: Run Android tests | |
run: | | |
bundle exec fastlane tests build_type:$APP_BUILD_TYPE | |
- name: Upload reports | |
if: ${{ always() }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: reports | |
path: | | |
**/build/reports/lint-*.html | |
**/build/reports/tests | |
build: | |
name: PR build | |
runs-on: ubuntu-latest | |
environment: | |
name: release | |
if: ${{ needs.bump_version.outputs.bumped == 'false' }} | |
needs: bump_version | |
steps: | |
- name: Install packages | |
run: sudo apt install autopoint | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Setup asdf | |
uses: asdf-vm/actions/[email protected] | |
- name: Install asdf plugins | |
uses: asdf-vm/actions/[email protected] | |
- name: Setup required Java | |
run: | | |
asdf install java && | |
echo "JAVA_HOME=$(asdf where java)" >> "$GITHUB_ENV" | |
- name: Setup required Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
# Check that fastlane has changelog for the new version | |
- name: Check Fastlane changelog | |
if: ${{ env.RELEASE_CANDIDATE == 'true' }} | |
run: | | |
locales="" | |
for dir in fastlane/metadata/android/*/; do | |
if [[ ! -f "${dir}/changelogs/${{ needs.bump_version.outputs.version_code }}.txt" ]]; then | |
locales="${locales}- *$(basename $dir)*\n" | |
fi | |
done | |
if [[ ! -z "$locales" ]]; then | |
msg=":exclamation: There is no Fastlane changelog for locales:\n\n${locales}\nIs it OK?" | |
bundle exec fastlane run issue_comment token:"${{ secrets.GITHUB_TOKEN }}" number:${{ github.event.number }} msg:"$(printf "${msg}")" | |
fi | |
- name: Cache Rust Cargo | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry | |
~/.cargo/git | |
./native/target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('./native/**/Cargo.lock', '**/rust-toolchain') }} | |
- name: Cache Gradle wrapper | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Validate Gradle Wrapper | |
uses: gradle/wrapper-validation-action@v1 | |
- name: Run assemble task | |
if: ${{ env.FORK == 'false' }} | |
run: | | |
bundle exec fastlane pr_build_apk build_type:"${APP_BUILD_TYPE}" store_data:"${SEENEVA_STORE_DATA}" | |
env: | |
SEENEVA_VERSION_NAME: ${{ needs.bump_version.outputs.version_name }} | |
SEENEVA_VERSION_CODE: ${{ needs.bump_version.outputs.version_code }} | |
SEENEVA_STORE_FILE: ${{ github.workspace }}/seeneva.keystore | |
SEENEVA_STORE_DATA: ${{ secrets.KEYSTORE }} | |
SEENEVA_STORE_PASS: ${{ secrets.KEYSTORE_PASS }} | |
SEENEVA_KEY_ALIAS: ${{ secrets.KEYSTORE_ALIAS }} | |
SEENEVA_KEY_PASS: ${{ secrets.KEY_PASS }} | |
FL_GRADLE_PRINT_COMMAND: false | |
- name: Run forked assemble task | |
if: ${{ env.FORK == 'true' }} | |
run: | | |
bundle exec fastlane pr_build_fork_apk build_type:"${APP_BUILD_TYPE}" | |
env: | |
SEENEVA_VERSION_NAME: ${{ needs.bump_version.outputs.version_name }} | |
SEENEVA_VERSION_CODE: ${{ needs.bump_version.outputs.version_code }} | |
- name: Upload APKs | |
uses: actions/upload-artifact@v3 | |
with: | |
name: apk | |
path: ./app/build/outputs/apk | |
if-no-files-found: error |