mirror of
https://github.com/wfxr/forgit.git
synced 2026-09-16 02:06:17 -04:00
Meta: Do not tag release without public changes (#427)
This is mostly a refactoring of our GitHub actions. The tag workflow and script have been removed completely, since the release action will implicitly create the release tag if it does not exit, yet. This makes sure that we do not create a tag when there will be no release. We have only one workflow now, which contains two jobs: one for generating the changelog and one for creating the release. The changelog job will generate the changelog and upload it as an artifact if there are public changes. The release version, which previously was determined in the tag script, is now determined within this job, so that we can pass it to the release job. The release job will run only if the changelog job was successful, i.e. if there are public changes. It will create a tag and a GitHub release with the given version number. The workflow will run on the first day of every month for our regular automatic monthly releases. It will also run on every tag push, so that we still can create a release manually if necessary. The release action will implicitly use the existing tag for the release then. Fixes #413 Closes #414
This commit is contained in:
parent
18f1a1e0c3
commit
aec8b1f2b5
21
.github/scripts/tag.sh
vendored
21
.github/scripts/tag.sh
vendored
|
|
@ -1,21 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
head_tag=$(git describe --exact-match 2>/dev/null || true)
|
||||
|
||||
git log --color=always --format="%C(auto)%h %s%d" | head
|
||||
|
||||
if [[ ${head_tag} =~ [\d{2}\.\d{2}\.\d+] ]]
|
||||
then
|
||||
echo "Version tag ${head_tag} already exists."
|
||||
else
|
||||
git config --local user.email "github-actions@users.noreply.github.com"
|
||||
git config --local user.name "github-actions"
|
||||
version=$(date +'%y.%m.0')
|
||||
git tag -a ${version} -m "Release ${version}"
|
||||
git push origin ${version}
|
||||
git log --color=always --format="%C(auto)%h %s%d" | head -1
|
||||
echo "Pushed new tag:"
|
||||
echo "${REPO_URL}/releases/tag/${version}"
|
||||
fi
|
||||
60
.github/workflows/release.yaml
vendored
60
.github/workflows/release.yaml
vendored
|
|
@ -1,32 +1,78 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# Run on every first day of the month
|
||||
- cron: '0 0 1 * *'
|
||||
push:
|
||||
tags:
|
||||
- '**'
|
||||
|
||||
jobs:
|
||||
|
||||
release:
|
||||
changelog:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Create Package
|
||||
run: tar -czf forgit-${{github.ref_name}}.tar.gz --exclude LICENSE --exclude README.md *
|
||||
|
||||
- name: Generate Changelog
|
||||
id: changelog
|
||||
run: .github/scripts/changelog.sh > CHANGELOG.md
|
||||
# When the script returns with an error, it indicates that we don't have
|
||||
# any public changes to be released. This is expected behavior, so we
|
||||
# quit the workflow successfully in this case.
|
||||
continue-on-error: true
|
||||
|
||||
- name: Upload Changelog
|
||||
uses: actions/upload-artifact@v4
|
||||
if: steps.changelog.outcome == 'success'
|
||||
with:
|
||||
name: changelog
|
||||
path: CHANGELOG.md
|
||||
|
||||
- name: Set version
|
||||
id: set_version
|
||||
if: steps.changelog.outcome == 'success'
|
||||
# Set version depending on whether this is a regular monthly release or
|
||||
# a custom release triggered by a tag push.
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" == "push" ]; then
|
||||
VERSION=${{ github.ref_name }}
|
||||
else
|
||||
VERSION=$(date +'%y.%m.0')
|
||||
fi
|
||||
echo "VERSION=$VERSION"
|
||||
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
|
||||
|
||||
outputs:
|
||||
changeLogOutcome: ${{ steps.changelog.outcome }}
|
||||
version: ${{ steps.set_version.outputs.VERSION }}
|
||||
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: changelog
|
||||
if: needs.changelog.outputs.changeLogOutcome == 'success'
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Download Changelog
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: changelog
|
||||
|
||||
- name: Create Package
|
||||
run: tar -czf forgit-${{ needs.changelog.outputs.version }}.tar.gz --exclude LICENSE --exclude README.md *
|
||||
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
if: steps.changelog.outcome == 'success'
|
||||
with:
|
||||
# The release action implicitly creates the tag if it does not exist.
|
||||
tag_name: ${{ needs.changelog.outputs.version }}
|
||||
body_path: CHANGELOG.md
|
||||
files: forgit-${{github.ref_name}}.tar.gz
|
||||
files: forgit-${{ needs.changelog.outputs.version }}.tar.gz
|
||||
|
|
|
|||
28
.github/workflows/tag.yaml
vendored
28
.github/workflows/tag.yaml
vendored
|
|
@ -1,28 +0,0 @@
|
|||
name: Tag
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# Run on every first day of the month
|
||||
- cron: '0 0 1 * *'
|
||||
|
||||
jobs:
|
||||
|
||||
tag:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
# The COMMIT_KEY secret contains a private SSH key. The associated public key
|
||||
# has been added as a deploy key in the GitHub project. See:
|
||||
# https://docs.github.com/en/developers/overview/managing-deploy-keys#deploy-keys
|
||||
# This is necessary to make commits done by github-actions able to trigger
|
||||
# further github-actions. See: https://stackoverflow.com/q/60418323/3018229.
|
||||
ssh-key: "${{secrets.COMMIT_KEY}}"
|
||||
|
||||
- name: Create Tag
|
||||
run: .github/scripts/tag.sh
|
||||
env:
|
||||
REPO_URL: ${{github.server_url}}/${{github.repository}}
|
||||
Loading…
Reference in a new issue