diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 285eeae..8acf2fb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,167 +16,7 @@ on: 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: | - # Získání aktuálního tagu - CURRENT_TAG=$(git describe --tags --abbrev=0 HEAD) - - # Funkce pro získání předchozího stabilního tagu - get_previous_stable_tag() { - PREV_TAG="" - # Procházej všechny tagy v obráceném pořadí (od nejnovějšího) - for tag in $(git tag --sort=-creatordate); do - # Pokud je tag stabilní (např. v1.0.0, v1.2.3, atd.), ale není stejný jako aktuální - if [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] && [[ "$tag" != "$CURRENT_TAG" ]]; then - PREV_TAG=$tag - break - fi - done - echo $PREV_TAG - } - - - # Pokud je aktuální tag beta nebo rc, najdi poslední stabilní verzi - if [[ "$CURRENT_TAG" =~ -beta || "$CURRENT_TAG" =~ -rc ]]; then - # Najdi poslední stabilní verzi (ignoruj beta/rc tagy) - PREV_TAG=$(git tag --sort=-creatordate | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1) - else - # Pokud je stabilní verze, použij předchozí stabilní tag - PREV_TAG=$(git tag --sort=-creatordate | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | grep -B 1 "$CURRENT_TAG" | head -n 1) - fi - - if [[ "$CURRENT_TAG" == "$PREV_TAG" ]]; then - echo "Current tag is the same as the previous tag, using the previous stable tag." - PREV_TAG=$(get_previous_stable_tag) - fi - - if [ -z "$PREV_TAG" ]; then - echo "No previous tag found, using initial commit." - PREV_TAG=$(git rev-list --max-parents=0 HEAD) - fi - - echo "PREV TAG: $PREV_TAG" - echo "CURRENT TAG: $CURRENT_TAG" - - COMMITS="" - - # Odstranění nechtěných znaků - COMMITS=$(echo "$COMMITS" | sed 's/[[:cntrl:]]//g') - 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 }} \ No newline at end of file + call-release: + uses: gouef/github-lib-template/.github/workflows/shared_release.yml@main + with: + branch: ${{ github.ref_name }} \ No newline at end of file