wgtunnel/.github/workflows/publish.yml

257 lines
8.3 KiB
YAML
Raw Normal View History

2024-12-25 23:19:31 -05:00
name: publish
on:
schedule:
2024-10-14 00:26:49 -04:00
- cron: "4 3 * * *"
2024-01-20 20:57:39 -05:00
workflow_dispatch:
2024-07-27 04:15:57 -04:00
inputs:
track:
type: choice
description: "Google play release track"
options:
- none
- internal
- alpha
- beta
- production
2024-09-20 01:37:26 -04:00
default: none
2024-07-27 04:15:57 -04:00
required: true
release_type:
type: choice
description: "GitHub release type"
options:
- none
- prerelease
- nightly
- release
default: release
required: true
tag_name:
description: "Tag name for release"
required: false
default: nightly
2024-09-20 01:37:26 -04:00
workflow_call:
2024-12-25 22:43:26 -05:00
env:
UPLOAD_DIR_ANDROID: android_artifacts
jobs:
2024-10-14 00:11:26 -04:00
check_commits:
2024-11-03 17:11:06 -05:00
name: Check for New Commits
runs-on: ubuntu-latest
2024-11-03 17:11:06 -05:00
outputs:
has_new_commits: ${{ steps.check.outputs.new_commits }}
steps:
2024-11-03 17:11:06 -05:00
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # This fetches all history so we can check commits
2024-10-14 00:11:26 -04:00
2024-11-03 17:11:06 -05:00
- name: Check for new commits
id: check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2024-10-14 00:11:26 -04:00
run: |
2024-11-03 17:11:06 -05:00
# This script checks for commits newer than 23 hours ago
NEW_COMMITS=$(git rev-list --count --after="$(date -Iseconds -d '23 hours ago')" ${{ github.sha }})
echo "new_commits=$NEW_COMMITS" >> $GITHUB_OUTPUT
2024-12-25 22:43:26 -05:00
build:
2024-12-25 22:43:26 -05:00
if: ${{ inputs.release_type != 'none' }}
uses: ./.github/workflows/build.yml
secrets: inherit
with:
build_type: ${{ inputs.release_type == '' && 'nightly' || inputs.release_type }}
publish:
2024-12-25 23:19:31 -05:00
needs:
2024-12-25 22:43:26 -05:00
- check_commits
- build
2024-11-03 17:13:43 -05:00
if: ${{ needs.check_commits.outputs.has_new_commits > 0 && inputs.release_type != 'none' }}
2024-12-31 00:27:29 -05:00
name: publish-github
runs-on: ubuntu-latest
env:
GH_USER: ${{ secrets.GH_USER }}
2024-07-27 23:18:30 -04:00
# GH needed for gh cli
GH_TOKEN: ${{ secrets.GH_TOKEN }}
2024-07-27 23:18:30 -04:00
GH_REPO: ${{ github.repository }}
steps:
2024-12-31 00:27:29 -05:00
- uses: actions/checkout@v4
2024-07-27 04:20:35 -04:00
- name: Install system dependencies
run: |
sudo apt update && sudo apt install -y gh apksigner
2024-11-12 23:11:55 -05:00
# update latest tag
- name: Set latest tag
uses: rickstaa/action-create-tag@v1
id: tag_creation
with:
tag: "latest" # or any tag name you wish to use
message: "Automated tag for HEAD commit"
force_push_tag: true
tag_exists_error: false
- name: Get latest release
id: latest_release
uses: kaliber5/action-get-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
latest: true
- name: Generate Changelog
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
toTag: ${{ github.event_name == 'schedule' && 'nightly' || steps.latest_release.outputs.tag_name }}
fromTag: "latest"
writeToFile: false # we won't write to file, just output
2024-01-20 20:45:44 -05:00
- name: Get version code
2024-07-29 17:14:08 -04:00
if: ${{ inputs.release_type == 'release' }}
2024-01-20 20:45:44 -05:00
run: |
2024-01-20 20:57:39 -05:00
version_code=$(grep "VERSION_CODE" buildSrc/src/main/kotlin/Constants.kt | awk '{print $5}' | tr -d '\n')
2024-01-20 20:45:44 -05:00
echo "VERSION_CODE=$version_code" >> $GITHUB_ENV
2024-07-27 04:15:57 -04:00
- name: Push changes
2024-09-16 01:14:28 -04:00
if: ${{ inputs.release_type == '' || inputs.release_type == 'nightly' || inputs.release_type == 'prerelease' }}
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
2024-12-25 22:43:26 -05:00
- name: Make download dir
run: mkdir ${{ github.workspace }}/temp
2024-12-25 23:19:31 -05:00
2024-12-25 22:43:26 -05:00
- name: Download artifacts
uses: actions/download-artifact@v4
with:
2024-12-25 22:43:26 -05:00
name: ${{ env.UPLOAD_DIR_ANDROID }}
path: ${{ github.workspace }}/temp
2024-07-27 04:15:57 -04:00
# Setup TAG_NAME, which is used as a general "name"
- if: github.event_name == 'workflow_dispatch'
run: echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
- if: github.event_name == 'schedule'
run: echo "TAG_NAME=nightly" >> $GITHUB_ENV
2024-07-27 04:15:57 -04:00
- name: Set version release notes
2024-07-29 17:14:08 -04:00
if: ${{ inputs.release_type == 'release' }}
2024-07-27 04:15:57 -04:00
run: |
RELEASE_NOTES="$(cat ${{ github.workspace }}/fastlane/metadata/android/en-US/changelogs/${{ env.VERSION_CODE }}.txt)"
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
echo "$RELEASE_NOTES" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
2024-07-29 17:14:08 -04:00
- name: On nightly release notes
2024-07-27 04:15:57 -04:00
if: ${{ contains(env.TAG_NAME, 'nightly') }}
run: |
echo "RELEASE_NOTES=Nightly build for the latest development version of the app." >> $GITHUB_ENV
2024-07-27 04:15:57 -04:00
gh release delete nightly --yes || true
git push origin :nightly || true
2024-07-27 04:15:57 -04:00
2024-07-29 17:14:08 -04:00
- name: On prerelease release notes
if: ${{ inputs.release_type == 'prerelease' }}
run: |
echo "RELEASE_NOTES=Testing version of app for specific feature." >> $GITHUB_ENV
gh release delete ${{ github.event.inputs.tag_name }} --yes || true
2024-07-27 04:15:57 -04:00
- name: Get checksum
id: checksum
2024-12-25 22:43:26 -05:00
run: |
file_path=$(find ${{ github.workspace }}/temp -type f -iname "*.apk" | tail -n1)
echo "checksum=$(apksigner verify -print-certs $file_path | grep -Po "(?<=SHA-256 digest:) .*" | tr -d "[:blank:]")" >> $GITHUB_OUTPUT
2024-07-27 04:15:57 -04:00
- name: Create Release with Fastlane changelog notes
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body: |
2024-07-27 04:15:57 -04:00
${{ env.RELEASE_NOTES }}
2024-07-29 17:14:08 -04:00
SHA256 fingerprint:
```${{ steps.checksum.outputs.checksum }}```
2024-11-12 23:11:55 -05:00
### Changelog
${{ steps.changelog.outputs.changes }}
2024-07-27 04:15:57 -04:00
tag_name: ${{ env.TAG_NAME }}
name: ${{ env.TAG_NAME }}
draft: false
2024-07-27 04:18:04 -04:00
prerelease: ${{ inputs.release_type == 'prerelease' || inputs.release_type == '' || inputs.release_type == 'nightly' }}
2024-07-27 04:15:57 -04:00
make_latest: ${{ inputs.release_type == 'release' }}
2024-12-31 15:25:07 -05:00
files: |
${{ github.workspace }}/temp/*
2024-07-27 04:15:57 -04:00
2024-12-25 22:43:26 -05:00
publish-fdroid:
runs-on: ubuntu-latest
needs:
2024-12-26 22:34:00 -05:00
- build
2024-12-25 22:43:26 -05:00
if: inputs.release_type == 'release'
steps:
- name: Dispatch update for fdroid repo
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.ANDROID_PAT }}
repository: zaneschepke/fdroid
event-type: fdroid-update
2024-12-25 23:19:31 -05:00
2024-07-27 04:15:57 -04:00
publish-play:
if: ${{ inputs.track != 'none' && inputs.track != '' }}
name: Publish to Google Play
runs-on: ubuntu-latest
env:
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
KEY_STORE_FILE: 'android_keystore.jks'
KEY_STORE_LOCATION: ${{ github.workspace }}/app/keystore/
GH_USER: ${{ secrets.GH_USER }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
2024-07-27 04:15:57 -04:00
steps:
2024-07-27 07:42:02 -04:00
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
2024-07-28 14:05:15 -04:00
# Here we need to decode keystore.jks from base64 string and place it
# in the folder specified in the release signing configuration
- name: Decode Keystore
id: decode_keystore
uses: timheuer/base64-to-file@v1.2
with:
fileName: ${{ env.KEY_STORE_FILE }}
fileDir: ${{ env.KEY_STORE_LOCATION }}
encodedString: ${{ secrets.KEYSTORE }}
# create keystore path for gradle to read
- name: Create keystore path env var
run: |
store_path=${{ env.KEY_STORE_LOCATION }}${{ env.KEY_STORE_FILE }}
echo "KEY_STORE_PATH=$store_path" >> $GITHUB_ENV
- name: Create service_account.json
id: createServiceAccount
run: echo '${{ secrets.SERVICE_ACCOUNT_JSON }}' > service_account.json
- name: Deploy with fastlane
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2' # Not needed with a .ruby-version file
bundler-cache: true
2024-07-27 07:42:02 -04:00
- name: Distribute app to Prod track 🚀
2024-07-27 04:15:57 -04:00
run: (cd ${{ github.workspace }} && bundle install && bundle exec fastlane ${{ inputs.track }})