Preview Builder #29
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: Preview Builder | |
# Manually build a standard preview on master | |
on: | |
# Dispatch or Manual triggers | |
workflow_dispatch: | |
# push: | |
# branches: | |
# - master | |
# paths: | |
# - '**' | |
# - '!**.md' | |
# - '!.github/**' | |
# - '.github/scripts/**' | |
# - '.github/workflows/**' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
prepare-build: | |
runs-on: ubuntu-latest | |
outputs: | |
VERSION_TAG: ${{ steps.get_tag.outputs.VERSION_TAG }} | |
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 }} | |
TAG_NAME: ${{ steps.prepare_env.outputs.TAG_NAME }} | |
PREV_TAG_NAME: ${{ steps.previous_commit.outputs.PREV_TAG_NAME }} | |
steps: | |
- name: Get tag name (${{ github.ref }}) | |
id: get_tag | |
run: | | |
set -x | |
echo "VERSION_TAG=${GITHUB_REF/refs\/heads\//}" | |
echo "VERSION_TAG=${GITHUB_REF/refs\/heads\//}" >> $GITHUB_OUTPUT | |
- name: Clone Repository (${{ steps.get_tag.outputs.VERSION_TAG }}) | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 | |
- name: Validate Gradle Wrapper | |
uses: gradle/actions/wrapper-validation@d156388eb19639ec20ade50009f3d199ce1e2808 # v4 | |
- 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: 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 | |
commit_count_diff=$(git rev-list --count "${{ steps.last_release.outputs.tag_name }}"..HEAD) | |
# Fake at least 1 commits (to avoid no changes) | |
if [ "${commit_count_diff}" -eq 0 ]; then | |
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 }}" | |
echo "PREV_TAG_NAME=${{ steps.last_release.outputs.tag_name }}" >> $GITHUB_OUTPUT | |
- name: Prepare env | |
id: prepare_env | |
run: | | |
set -e | |
tag_prefix=r | |
artifacts_prefix=standard/preview/app-standard | |
build_type_name=Preview | |
echo "TAG_NAME=${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" | |
echo "ARTIFACTS_PREFIX=$artifacts_prefix" >> $GITHUB_OUTPUT | |
echo "BUILD_TYPE_NAME=$build_type_name" | |
echo "BUILD_TYPE_NAME=$build_type_name" >> $GITHUB_OUTPUT | |
- name: Commit logs | |
id: commit_logs | |
run: | | |
set -e | |
echo "COMMIT_LOGS<<{delimiter} | |
$(curl -H "Accept: application/vnd.github.v3+json" \ | |
"https://api.github.com/repos/komikku-app/komikku/compare/${{ steps.previous_commit.outputs.PREV_RELEASE_SHA }}...${{ steps.current_commit.outputs.CURRENT_SHA }}" \ | |
| jq '[.commits[]|{message:(.commit.message | split("\n")), username:.author.login}]' \ | |
| jq -r '.[]|"- \(.message | first) (@\(.username))"') | |
{delimiter}" >> $GITHUB_OUTPUT |