diff --git a/.github/workflows/build_application.yml b/.github/workflows/build_application.yml index b90b74fc..300d9e3b 100644 --- a/.github/workflows/build_application.yml +++ b/.github/workflows/build_application.yml @@ -23,21 +23,74 @@ env: releaseType: prerelease jobs: - make_version: + update_revision_number: runs-on: ubuntu-latest + outputs: - build_num: ${{ steps.generate_build_number.outputs.build_num }} + revision_number: ${{ steps.revision.outputs.revision_number }} steps: - - name: Checkout code + - name: Checkout repository uses: actions/checkout@v4 - + + - name: Restore cache + id: cache + uses: actions/cache@v2 + with: + path: cache_dir + key: revision-number + + - name: Get current date + id: date + run: echo "current_date=$(date +'%Y-%m-%d')" >> $GITHUB_ENV + + - name: Check and update revision number + id: revision + run: | + FILENAME=cache_dir/revision_number.txt + DATEFILE=cache_dir/previous_date.txt + + mkdir -p cache_dir + + if [ -f "$DATEFILE" ]; then + prev_date=$(cat "$DATEFILE") + rev_number=$(cat "$FILENAME") + else + prev_date="" + rev_number=0 + fi + + if [ "$current_date" = "$prev_date" ]; then + rev_number=$((rev_number + 1)) + else + rev_number=1 + fi + + echo "New revision number: $rev_number" + echo $rev_number > "$FILENAME" + echo $current_date > "$DATEFILE" + echo "revision_number=$rev_number" >> $GITHUB_OUTPUT + + - name: Save cache + uses: actions/cache@v2 + with: + path: cache_dir + key: revision-number + + make_version: + runs-on: ubuntu-latest + needs: [ update_revision_number ] + + outputs: + build_num: ${{ steps.generate_build_number.outputs.build_num }} + env: + revisionNumber: ${{ needs.update_revision_number.outputs.revision_number }} + + steps: - name: Make build number id: generate_build_number run: | - today=$(date +%Y-%m-%d) - commit_count=$(git rev-list --count --since="$today 00:00:00" --until="$today 23:59:59") - build_num=$(date +'%Y.%-m.%-d').$(commit_count) + build_num=$(date +'%Y.%-m.%-d').${{ env.revisionNumber }} echo "build_num=$build_num" >> $GITHUB_OUTPUT echo "Build number is $build_num" @@ -55,6 +108,9 @@ jobs: buildNumber: ${{ needs.make_version.outputs.build_num }} steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Setup .NET SDK uses: actions/setup-dotnet@v4 with: