Skip to content

enh(CI): Automatic Release Workflow #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/installer-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
installer-sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Check nanorc included every *nanorc files
run: |
Expand Down
95 changes: 95 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: release

on:
schedule:
- cron: '0 0 1 */1 *' # @monthly
workflow_dispatch:
inputs:
release_tag:
type: string
required: false
environment:
type: environment
required: true
default: release

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true

jobs:
verify:
runs-on: ubuntu-latest
outputs:
release_tag: ${{ steps.verify.outputs.release_tag }}
release_commit: ${{ steps.verify.outputs.release_commit }}
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true
# FIXME: workaround for git 2.48, see https://github.com/actions/checkout/issues/1467
fetch-depth: 100
ref: ${{ github.ref }}

- name: Verify release tag
id: verify
env:
INPUT_RELEASE_TAG: ${{ inputs.release_tag }}
REPOSITORY_URL: '${{ github.server_url }}/${{ github.repository }}'
run: |
set -eu
latest_tag="$(git describe --tags --abbrev=0)"
latest_tag_fmt="[\`${latest_tag}\`](${REPOSITORY_URL}/releases/tag/${latest_tag})"
release_tag="${INPUT_RELEASE_TAG:-$(date +'%Y.%m.%d')}"
release_commit="$(git log --format="%H" -n 1)"
# note: this comparison only works with lexicographic dates
if [[ ! "${release_tag}" > "${latest_tag}" ]]; then
echo "## Skipping release \`${release_tag}\`" >> "$GITHUB_STEP_SUMMARY"
echo "Latest tag ${latest_tag_fmt} already covers this date." >> "$GITHUB_STEP_SUMMARY"
exit 0
elif [[ "$(git log --format="%H" -n 1 "${latest_tag}")" = "${release_commit}" ]]; then
echo "## Skipping release \`${release_tag}\`" >> "$GITHUB_STEP_SUMMARY"
echo "No changes since ${latest_tag_fmt}." >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
{
echo "## Proposing new release \`${release_tag}\`"
echo "Commit: [${release_commit}](${REPOSITORY_URL}/commit/${release_commit})"
echo "### Changes since ${latest_tag_fmt}"
echo '```log'
git diff --histogram --stat "${latest_tag}..${release_commit}"
echo '```'
echo '### Git log'
echo '```log'
git log --no-merges "${latest_tag}..${release_commit}"
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
echo "release_tag=${release_tag}" >> "$GITHUB_OUTPUT"
echo "release_commit=${release_commit}" >> "$GITHUB_OUTPUT"
release:
runs-on: ubuntu-latest
needs: [verify]
if: needs.verify.outputs.release_tag != ''
environment: ${{ inputs.environment || 'release' }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.verify.outputs.release_commit }}

- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.verify.outputs.release_tag }}
name: ${{ needs.verify.outputs.release_tag }}
target_commitish: ${{ needs.verify.outputs.release_commit }}
generate_release_notes: true
make_latest: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14 changes: 6 additions & 8 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,20 @@ jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: ShellCheck
uses: ludeeus/action-shellcheck@1.1.0
uses: ludeeus/action-shellcheck@2.0.0
#with:
# A space separated list of additional filename to check
#additional_files: # optional, default is
#additional_files: # optional, default is ''
# Paths to ignore when running ShellCheck
#ignore: # optional, default is
#ignore_paths: # optional, default is ''
# Minimum severity of errors to consider. Options: [error, warning, info, style]
#severity: # optional, default is
#severity: # optional, default is ''
# Run shellcheck on _all_ files at once, instead of one at a time
#check_together: # optional, default is
#check_together: # optional, default is ''
# Directory to be searched for files. Defaults to .
#scandir: # optional, default is .
# Set to true to skip using problem-matcher
#disable_matcher: # optional, default is false
# Output format (checkstyle, diff, gcc, json, json1, quiet, tty)
#format: # optional, default is gcc