Skip to content

Commit

Permalink
feat: workflow in a single job
Browse files Browse the repository at this point in the history
This is the simple straight forward workflow
  • Loading branch information
Arc-E-Tect committed Jul 22, 2024
1 parent a5b66a6 commit f95e292
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/release_in_one_job.yml
Original file line number Diff line number Diff line change
@@ -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/[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]"

0 comments on commit f95e292

Please sign in to comment.