Skip to content

Release in one job

Release in one job #1

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/[email protected]
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/[email protected]
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: "[email protected]"
GIT_AUTHOR_NAME: "Arc-E-Tect"
GIT_AUTHOR_EMAIL: "[email protected]"