Skip to content

Commit

Permalink
gh-releae workflow migration
Browse files Browse the repository at this point in the history
  • Loading branch information
maso7 committed Apr 18, 2023
1 parent 3acc704 commit 74b8ec8
Showing 1 changed file with 6 additions and 69 deletions.
75 changes: 6 additions & 69 deletions .github/workflows/gh-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,72 +8,9 @@ on:

jobs:
gh-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 20

- name: Get tags
id: tag
run: |
git fetch --tags
CURRENT_TAG=$(git describe --abbrev=0 --tags 2>/dev/null || true )
PREVIOUS_TAG=$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1) 2>/dev/null || true)
echo "previous tag: ${PREVIOUS_TAG}"
echo "current tag: ${CURRENT_TAG}"
echo "previous_tag=${PREVIOUS_TAG}" >> $GITHUB_OUTPUT
echo "current_tag=${CURRENT_TAG}" >> $GITHUB_OUTPUT
# Exit if there's any tag
if [[ ! -n "${CURRENT_TAG}" ]]; then
# Create annotation
echo "::error::Can't get any tag, create one, then release can be published."
exit 1
fi
- name: Changelog presence
id: changelog
env:
CHANGELOG_FILE: 'CHANGELOG.md'
run: |
if [[ -f ${{ env.CHANGELOG_FILE }} ]]; then
echo "changelog=true" >> $GITHUB_OUTPUT
fi
- name: Release commits
id: commits
env:
PREVIOUS_TAG: ${{ steps.tag.outputs.previous_tag }}
CURRENT_TAG: ${{ steps.tag.outputs.current_tag }}
run: |
COMMITS=$(git log --oneline --no-decorate $([[ "${{ env.PREVIOUS_TAG }}" ]] && echo "${{ env.PREVIOUS_TAG }}..") ${{ env.CURRENT_TAG }} | tr '"' "'" | while read LINE; do echo -n ${LINE}\\n; done)
echo "commits=${COMMITS}" >> $GITHUB_OUTPUT
# Export commits output through javascript to properly process multiline string
- name: Commits output
id: commits_output
uses: actions/[email protected]
with:
script: |
core.setOutput("commits", `${{ steps.commits.outputs.commits }}`);
- name: Release
uses: softprops/action-gh-release@v1
env:
CHANGELOG_FILE: 'CHANGELOG.md'
PREVIOUS_TAG: ${{ steps.tag.outputs.previous_tag }}
CURRENT_TAG: ${{ steps.tag.outputs.current_tag }}
with:
tag_name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || steps.tag.outputs.current_tag }}
draft: false
prerelease: false
body: |
#### Commits in this release:
${{ steps.commits_output.outputs.commits }}
#### Changelog:
${{ format('[`{0}..{1}`]({2}/{3}/compare/{0}..{1})', env.PREVIOUS_TAG, env.CURRENT_TAG, github.server_url, github.repository) }}
${{ steps.changelog.outputs.changelog == 'true' && format('[{0}]({1}/{2}/blob/{3}/{0})', env.CHANGELOG_FILE, github.server_url, github.repository, github.ref_name) || '' }}
uses: pixelfederation/gh-action-gh-release/.github/workflows/[email protected]
with:
# If enabled, respects commits between SemVer tag build num iterations instead of previous commited tag (eg: X.X.X-y_2 -> X.X.X-y_3)
tag_num: false
fetch_depth: '30'
changelog_file: 'CHANGELOG.md'

0 comments on commit 74b8ec8

Please sign in to comment.