Skip to content

Commit

Permalink
fix: changelog file name should be unique
Browse files Browse the repository at this point in the history
  • Loading branch information
netbe committed Apr 10, 2024
1 parent d946e0b commit f21eac4
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 24 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/_reusable_app_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
- name: 'Set date variable'
id: date
run: echo "::set-output name=date::$(date +%s%N)"
run: echo "date::$(date +%s%N)" >> $GITHUB_OUTPUT

- name: 'Upload changelog'
id: upload-file
Expand Down Expand Up @@ -199,18 +199,14 @@ jobs:
if: always()
uses: actions/upload-artifact@v4
with:
name: post-build-env
name: post-build-env-${{ inputs.fastlane_action }}
path: |
**/.post_build/*.env
- name: Load .env file
if: always()
uses: xom9ikk/[email protected]
with:
path: fastlane/.post_build
- uses: akiojin/[email protected]
id: base64-decoded-RELEASE_NOTES
with:
base64: ${{ env.RELEASE_NOTES }}
- uses: akiojin/[email protected]
id: base64-decoded-S3_PATHS
with:
Expand Down
48 changes: 30 additions & 18 deletions .github/workflows/c1_c2_c3_app_release_restricted.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
name: C1 C2 C3 Restricted

on: workflow_dispatch

permissions:
checks: write
on:
workflow_dispatch:
inputs:
column:
description: 'Select the column to release (C1, C2, C3, all)'
type: choice
options:
- C1
- C2
- C3
- all
required: true
default: 'all'

jobs:
column_1_restricted:
uses: ./.github/workflows/_reusable_app_release.yml
with:
fastlane_action: appstore_col_1_restricted
secrets: inherit

column_2_restricted:
uses: ./.github/workflows/_reusable_app_release.yml
changelog:
uses: ./.github/workflows/changelog.yml
with:
fastlane_action: appstore_col_2_restricted
secrets: inherit

column_3_restricted:
cloud: false
release:
needs: changelog
strategy:
matrix:
app_config:
- column: C1
fastlane_action: "appstore_col_1_restricted"
- column: C2
fastlane_action: "appstore_col_2_restricted"
- column: C3
fastlane_action: "appstore_col_3_restricted"
if: contains(inputs.column, matrix.app_config.column) || inputs.column == 'all'
uses: ./.github/workflows/_reusable_app_release.yml
with:
fastlane_action: appstore_col_3_restricted
secrets: inherit
fastlane_action: ${{ matrix.app_config.fastlane_action }}
changelog-url: ${{ needs.changelog.outputs.changelog-url }}
78 changes: 78 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
on:
workflow_call:
inputs:
cloud:
required: true
type: boolean
default: true

env: # https://docs.fastlane.tools/getting-started/ios/setup/
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8

permissions:
checks: write

jobs:
changelog:
runs-on: ubuntu-latest
outputs:
changelog-url: ${{ steps.expose-url.outputs.changelog }}
steps:
- name: 'Checkout Git repository with history for all branches and tags'
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 'Tag regex'
id: regex
run: |
if ${{ inputs.cloud }}; then
echo "regex='appstore/[0-9]+\.[0-9]+\.[0-9]*'" >> $GITHUB_ENV
else
echo "regex='bk_build/[0-9]+\.[0-9]+\.[0-9]*'" >> $GITHUB_ENV
fi
- name: 'Calculate diff between HEAD and latest tag'
run: echo "HEAD_TAG_DIFF=$(git diff HEAD $(git tag | grep -E '${{ env.regex }}' | tail -n 1) | wc -l | xargs)" >> "$GITHUB_ENV"

- name: 'Set current Git tag to HEAD'
if: "${{ env.HEAD_TAG_DIFF != '0' }}"
run: echo "CURRENT_TAG=$(git rev-parse HEAD)" >> "$GITHUB_ENV"
- name: 'Set previous Git tag to latest tag if comparing to head'
if: "${{ env.HEAD_TAG_DIFF != '0' }}"
run: echo "PREVIOUS_TAG=$(git tag | grep -E '${{ env.regex }}' | tail -n 1)" >> "$GITHUB_ENV"

- name: 'Set current Git tag to latest tagged commit'
if: "${{ env.HEAD_TAG_DIFF == '0' }}"
run: echo "CURRENT_TAG=$(git tag | grep -E '${{ env.regex }}' | tail -n 1)" >> "$GITHUB_ENV"
- name: 'Set previous Git tag previous tag because head is latest tag'
if: "${{ env.HEAD_TAG_DIFF == '0' }}"
run: echo "PREVIOUS_TAG=$(git tag | grep -E '${{ env.regex }}' | tail -n 2 | head -n 1)" >> "$GITHUB_ENV"

- name: 'Print environment variables'
run: |
echo -e "PREVIOUS_TAG = $PREVIOUS_TAG"
echo -e "CURRENT_TAG = $CURRENT_TAG"
echo -e "Node.js version = $(node --version)"
- name: 'Generate changelog'
run: |
echo "{}" > ./package.json
npx [email protected] -t "$PREVIOUS_TAG...$CURRENT_TAG"
- name: 'Set date variable'
id: date
run: echo "date=$(date +%s%N)" >> $GITHUB_OUTPUT

- name: 'Upload changelog'
id: upload-file
uses: actions/upload-artifact@v4
with:
name: CHANGELOG-${{ github.run_number }}-${{ steps.date.outputs.date }}.md
path: ./CHANGELOG.md
if-no-files-found: error
overwrite: true

- name: Expose url of changelog
id: expose-url
run: echo "changelog=${{ steps.upload-file.outputs.artifact-url }}" >> $GITHUB_OUTPUT

0 comments on commit f21eac4

Please sign in to comment.