diff --git a/.github/workflows/release_in_one_job.yml b/.github/workflows/release_in_one_job.yml new file mode 100644 index 0000000..5fa694e --- /dev/null +++ b/.github/workflows/release_in_one_job.yml @@ -0,0 +1,69 @@ +name: Release in one job +on: + workflow_dispatch: + +jobs: + Release: + name: Release + permissions: + contents: write + issues: write + pull-requests: write + + runs-on: ubuntu-latest + + env: + FILE: app/build.gradle + VERSION_REGEX: version\s*=\s*'[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+' + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + persist-credentials: false + + - name: cache NPM + uses: actions/cache@v4.0.2 + id: npm-cache + with: + path: | + **/node_modules + ${{ needs.install.outputs.npm-cache-dir }} + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Setup Node.js environment + uses: actions/setup-node@v4.0.3 + with: + node-version: "lts/*" + + - name: Install dependencies + run: npm ci + + - name: Calculate semantic version + id: calculate_semantic_version + run: | + export NEXT_TAG_VERSION=$(npx semantic-release --dry-run | grep 'The next release version is' | sed -E 's/.* ([[:digit:].]+)$/\1/') + echo "new_tag_version=${NEXT_TAG_VERSION}" >> $GITHUB_OUTPUT + echo "new_tag_version=${NEXT_TAG_VERSION}" + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + + - name: Update version and date in file + if: ${{ steps.calculate_semantic_version.new_tag_version != '' }} + run: | + VERSION=${{ steps.calculate_semantic_version.new_tag_version }} + + sed -i "s/${{ env.VERSION_REGEX }}/version = '$VERSION'/g" ${{ env.FILE }} + + - name: Apply release + if: ${{ steps.calculate_semantic_version.new_tag_version != '' }} + run: npx semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + GIT_COMMITTER_NAME: "Arc-E-Tect" + GIT_COMMITTER_EMAIL: "sedr@arc-e-tect.com" + GIT_AUTHOR_NAME: "Arc-E-Tect" + GIT_AUTHOR_EMAIL: "sedr@arc-e-tect.com"