forked from lablabs/ansible-role-openresty
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
6 additions
and
69 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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' |