Skip to content

Release

Release #89

Workflow file for this run

name: 'Release'
on:
workflow_dispatch:
inputs:
release:
type: choice
description: 'Version as:'
required: true
options:
- template
- application
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GITHUB_EMAIL: ${{ secrets.GH_EMAIL }}
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
NODE_VERSION: '22.18.0-alpine3.22'
jobs:
release:
runs-on: ubuntu-latest
strategy:
matrix:
node: ['22.20.0']
name: 'Release'
steps:
- name: '⚙ Setup NodeJS v${{ matrix.node }}'
uses: actions/[email protected]
with:
node-version: ${{ matrix.node }}
- name: '✅ Checkout repository'
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: '💾 Restore Dependencies from cache'
uses: actions/[email protected]
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: '🦉 GitGuardian scan'
uses: GitGuardian/[email protected]
env:
GITHUB_PUSH_BEFORE_SHA: ${{ github.event.before }}
GITHUB_PUSH_BASE_SHA: ${{ github.event.base }}
GITHUB_PULL_BASE_SHA: ${{ github.event.pull_request.base.sha }}
GITHUB_DEFAULT_BRANCH: ${GITHUB_REF##*/}
GITGUARDIAN_API_KEY: ${{ secrets.GITGUARDIAN_API_KEY }}
- name: '📦 Install packages'
run: yarn install
- name: '💅 Lint'
run: yarn lint:format:check
- name: '🔨 Build'
run: yarn build
- name: '👨‍💻 Run Test'
run: yarn test
env:
NODE_ENV: 'test'
- name: '📊 Publish Test Report'
uses: dorny/test-reporter@v2
if: ${{ !cancelled() }}
with:
name: 'Test Report (${{ matrix.node }})'
path: 'junit.xml'
reporter: jest-junit
- name: '📊 Upload coverage report to Codecov'
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: '📊 SonarCloud Scan'
uses: sonarsource/[email protected]
with:
args: >
-Dsonar.organization=${{ github.repository_owner }}
-Dsonar.projectKey=${{ github.repository_owner }}_${{ github.event.repository.name }}
-Dsonar.projectName=${{ github.repository_owner }}_${{ github.event.repository.name }}
-Dsonar.projectVersion=1.0
-Dsonar.sourceEncoding=UTF-8
-Dsonar.sources=./src
-Dsonar.exclusions=**/*.bin,node_modules/**,test/**,**/__test__/**,**/__mocks__/**,src/main.ts
-Dsonar.coverage.exclusions=node_modules/**,test/**,**/__test__/**,**/__mocks__/**,src/main.ts
-Dsonar.testExecutionReportPaths=test-report.xml
-Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
#- name: "🦠 Snyk to check for vulnerabilities"
# uses: snyk/actions/node@master
# env:
# SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
- name: '🏷️ Create Release'
id: Release
run: |
git config --global user.name "GitHub CI/CD bot"
git config --global user.email "${GITHUB_EMAIL}"
if ${{github.event.inputs.release == 'template'}}; then
yarn release --packageFiles 'version.txt' --bumpFiles 'version.txt'
else
yarn release
fi
git push --follow-tags origin master
tag=$(git describe --tags $(git rev-list --tags --max-count=1))
echo "tag=$tag" >> $GITHUB_OUTPUT
- name: '📄 Create Changelog'
id: Changelog
run: |
git fetch --tags
tag=$(git tag --sort version:refname | tail -n 2 | head -n 1)
if [ "$tag" ]; then
changelog=$(git log --oneline --no-decorate "$tag"..HEAD)
else
changelog=$(git log --oneline --no-decorate)
fi
changelog="${changelog//'%'/'%25'}"
changelog="${changelog//$'\n'/'%0A' - }"
changelog=" - ${changelog//$'\r'/'%0D'}"
echo "changelog=$changelog" >> "$GITHUB_OUTPUT"
- name: '🚀 Publish Release'
uses: actions/create-release@v1
with:
tag_name: '${{steps.Release.outputs.tag}}'
release_name: '${{steps.Release.outputs.tag}}'
body: |
${{ steps.Changelog.outputs.changelog }}
---
> 💬 All notable changes to this project will be documented in [Changelog](${{ github.event.repository.html_url }}/blob/master/CHANGELOG.md) file.
draft: false
prerelease: false
- name: '🔁 Rebase'
run: |
git remote set-url origin "https://github.com/${{ github.repository }}.git"
git config --global user.name "GitHub CI/CD bot"
git config --global user.email "${GITHUB_EMAIL}"
git config pull.rebase true
git fetch
git stash push -m "ci: stash standard-version changes"
git checkout develop
git pull
git merge --no-ff -m "ci(rebase): merge master" origin/master
git push -f
- name: '🐳 Docker'
run: |
docker login -u ${DOCKER_USER} -p ${DOCKER_PASSWORD}
docker build --build-arg NODE_VERSION=${NODE_VERSION} -t ${{ github.event.repository.name }} .
docker tag ${{ github.event.repository.name }} ${DOCKER_USER}/${{ github.event.repository.name }}:${{ github.sha }}
docker tag ${{ github.event.repository.name }} ${DOCKER_USER}/${{ github.event.repository.name }}:${{steps.Release.outputs.tag}}
docker tag ${{ github.event.repository.name }} ${DOCKER_USER}/${{ github.event.repository.name }}:latest
docker push ${DOCKER_USER}/${{ github.event.repository.name }}:${{ github.sha }}
docker push ${DOCKER_USER}/${{ github.event.repository.name }}:${{steps.Release.outputs.tag}}
docker push ${DOCKER_USER}/${{ github.event.repository.name }}:latest