Skip to content

Commit

Permalink
Added github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
JanGalek committed Dec 9, 2024
1 parent 49f88ac commit ada9591
Showing 1 changed file with 96 additions and 0 deletions.
96 changes: 96 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Create Release

on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name for the release'
required: true
default: 'v1.0.0'
release_type:
description: 'Release type (stable, beta, rc)'
required: true
default: 'stable'

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install GitHub CLI
run: |
sudo apt-get update
sudo apt-get install -y gh
- name: Authenticate GitHub CLI
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh auth setup-git

- name: Determine release type
id: release_type
run: |
TAG_NAME=${{ github.ref_name }}
if [[ "$TAG_NAME" == *beta* ]]; then
echo "release_type=Pre-release (Beta)" >> $GITHUB_ENV
echo "prerelease=true" >> $GITHUB_ENV
elif [[ "$TAG_NAME" == *rc* ]]; then
echo "release_type=Pre-release (Release Candidate)" >> $GITHUB_ENV
echo "prerelease=true" >> $GITHUB_ENV
else
echo "release_type=Stable" >> $GITHUB_ENV
echo "prerelease=false" >> $GITHUB_ENV
fi
- name: Get commits since last tag
id: commits
run: |
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
echo "No previous tag found, using initial commit."
COMMITS=$(git log --format="- %s (@%an)" HEAD)
else
COMMITS=""
while read -r commit_hash; do
COMMIT_MSG=$(git log -n 1 --pretty=format:"%s" "$commit_hash")
AUTHOR=$(gh api "/repos/${{ github.repository }}/commits/$commit_hash" --jq '.author.login')
COMMITS+="- $COMMIT_MSG (@$AUTHOR)"
COMMITS+=$'\n'
done < <(git log --format="%H" $PREV_TAG..HEAD)
fi
echo "commits=$COMMITS" >> $GITHUB_ENV
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create release
uses: ncipollo/release-action@v1
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: ${{ github.ref_name }}
body: |
${{ env.commits }}
draft: false
prerelease: ${{ env.prerelease }}
name: ${{ github.ref_name }} - ${{ env.release_type }}

# - name: Create release
# uses: actions/create-release@v1
# env:
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# tag_name: ${{ github.ref_name }}
# release_name: ${{ github.ref_name }} - ${{ env.release_type }}
# body: |
# ${{ env.commits }}
# draft: false
# prerelease: ${{ env.prerelease }}

0 comments on commit ada9591

Please sign in to comment.