Remote Dispatch Build Preview App #84
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: Remote Dispatch Build Preview App | |
on: | |
# Dispatch or Manual triggers | |
workflow_dispatch: | |
inputs: | |
git-ref: | |
description: Git Ref to build ('master' for standard preview release, any other for dev preview pre-release) | |
required: false | |
dry-run: | |
description: Creates a draft release (any value would create a draft) | |
required: false | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.inputs.git-ref }} | |
cancel-in-progress: true | |
jobs: | |
prepare-build: | |
if: github.event.inputs.git-ref != '' | |
runs-on: ubuntu-latest | |
outputs: | |
CURRENT_SHA: ${{ steps.current_commit.outputs.CURRENT_SHA }} | |
PREV_RELEASE_SHA: ${{ steps.previous_commit.outputs.PREV_RELEASE_SHA }} | |
COMMIT_LOGS: ${{ steps.commit_logs.outputs.COMMIT_LOGS }} | |
ARTIFACTS_PREFIX: ${{ steps.prepare_env.outputs.ARTIFACTS_PREFIX }} | |
BUILD_TYPE_NAME: ${{ steps.prepare_env.outputs.BUILD_TYPE_NAME }} | |
CHANGELOG: ${{ steps.set_changelog.outputs.CHANGELOG }} | |
TAG_NAME: ${{ steps.prepare_env.outputs.TAG_NAME }} | |
PREV_TAG_NAME: ${{ steps.previous_commit.outputs.PREV_TAG_NAME }} | |
steps: | |
- name: Clone Repository (${{ github.event.inputs.git-ref }}) | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
with: | |
repository: 'komikku-app/komikku' | |
fetch-depth: 0 | |
ref: ${{ github.event.inputs.git-ref }} | |
- name: Validate Gradle Wrapper | |
uses: gradle/actions/wrapper-validation@dbbdc275be76ac10734476cc723d82dfe7ec6eda # v3.4.2 | |
- name: Get previous release | |
id: last_release | |
uses: InsonusK/get-latest-release@7a9ff16c8c6b7ead5d71c0f1cc61f2703170eade # v1.1.0 | |
with: | |
myToken: ${{ github.token }} | |
exclude_types: "draft" | |
view_top: 1 | |
- name: "Last release result" | |
run: | | |
echo "id: ${{ steps.last_release.outputs.id }}" | |
echo "name: ${{ steps.last_release.outputs.name }}" | |
echo "tag_name: ${{ steps.last_release.outputs.tag_name }}" | |
echo "created_at: ${{ steps.last_release.outputs.created_at }}" | |
echo "draft: ${{ steps.last_release.outputs.draft }}" | |
echo "prerelease: ${{ steps.last_release.outputs.prerelease }}" | |
echo "url: ${{ steps.last_release.outputs.url }}" | |
echo "html_url: ${{ steps.last_release.outputs.html_url }}" | |
- name: Curren commit | |
id: current_commit | |
run: | | |
set -e | |
commit_count=$(git rev-list --count HEAD) | |
echo "COMMIT_COUNT=$commit_count" | |
echo "COMMIT_COUNT=$commit_count" >> $GITHUB_OUTPUT | |
current_sha=$(git rev-parse --short HEAD) | |
echo "CURRENT_SHA=$current_sha" | |
echo "CURRENT_SHA=$current_sha" >> $GITHUB_OUTPUT | |
- name: Previous commit | |
id: previous_commit | |
run: | | |
set -e | |
prev_commit_count=$(echo "${{ steps.last_release.outputs.tag_name }}" | sed -e "s/^r//") | |
echo "prev_commit_count=$prev_commit_count" | |
# Fake at least 1 commits (to avoid no changes) | |
if [ "${{ steps.current_commit.outputs.COMMIT_COUNT }}" -gt "$prev_commit_count" ]; then | |
commit_count_diff="$(expr ${{ steps.current_commit.outputs.COMMIT_COUNT }} - $prev_commit_count)" | |
else | |
commit_count_diff=1 | |
fi | |
echo "commit_count_diff=$commit_count_diff" | |
prev_release_sha=$(git rev-parse --short HEAD~$commit_count_diff) | |
echo "PREV_RELEASE_SHA=$prev_release_sha" | |
echo "PREV_RELEASE_SHA=$prev_release_sha" >> $GITHUB_OUTPUT | |
echo "PREV_TAG_NAME=${{ steps.last_release.outputs.tag_name }}" >> $GITHUB_OUTPUT | |
- name: Prepare env | |
id: prepare_env | |
run: | | |
set -e | |
if [ "${{ github.event.inputs.git-ref }}" = "master" ]; then | |
tag_prefix=r | |
artifacts_prefix=standard/preview/app-standard | |
build_type_name=Preview | |
else | |
tag_prefix=d | |
artifacts_prefix=dev/preview/app-dev | |
build_type_name="Dev build" | |
fi | |
echo "${tag_prefix}${{ steps.current_commit.outputs.COMMIT_COUNT }}" | |
echo "TAG_NAME=${tag_prefix}${{ steps.current_commit.outputs.COMMIT_COUNT }}" >> $GITHUB_OUTPUT | |
echo "ARTIFACTS_PREFIX=$artifacts_prefix" >> $GITHUB_OUTPUT | |
echo "BUILD_TYPE_NAME=$build_type_name" >> $GITHUB_OUTPUT |