Release workflow #19
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
permissions: | |
contents: write | |
actions: read | |
checks: write | |
deployments: write | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
- name: Install Dependencies | |
run: npm install | |
- name: Check if tag is present | |
id: tag_check | |
run: | | |
VERSION=$(jq -r '.version' package.json) | |
if git rev-parse "${VERSION}" >/dev/null 2>&1; then | |
echo "Tag v${VERSION} already exists." | |
echo "exists=true" >> $GITHUB_ENV | |
else | |
echo "Tag v${VERSION} does not exist." | |
echo "exists=false" >> $GITHUB_ENV | |
fi | |
echo "version=${VERSION}" >> $GITHUB_ENV | |
- name: Create npm package | |
run: npm pack | |
- name: Extract package contents | |
run: npm pack | |
id: npm_pack | |
- name: Checkout release branch | |
uses: actions/checkout@v4 | |
with: | |
ref: release | |
path: ./release | |
- name: Extract package contents | |
run: | | |
tar -xzf *.tgz --strip-components=1 -C ./release | |
- name: Push package contents to a new branch | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
cd ./release | |
git add . | |
git commit -m "Release v${{ env.VERSION }}" | |
echo "Pushing with message: Release v${{ env.VERSION }}" | |
- name: Generate release notes | |
run: | | |
cd ./release | |
PREV_TAG=$(git describe --tags --abbrev=0) | |
echo "${PREV_TAG}" | |
GIT_LOG=$(git log --pretty=format:"%h - %s (%an)" "${PREV_TAG}..HEAD") | |
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV | |
echo "${GIT_LOG}" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Printing release notes | |
run: | | |
echo ${{ env.RELEASE_NOTES }} | |
echo ${{ env.GIT_LOG }} | |
echo ${{ env.RELEASE_NOTES }} | |
echo v${{ steps.check.outputs.version }} | |
echo ${{ env.exists }} | |