Skip to content

Commit

Permalink
Automatically create a release when version changes in CMakeLists
Browse files Browse the repository at this point in the history
  • Loading branch information
hzeller committed Jul 16, 2023
1 parent 6530ec1 commit 75e46ff
Showing 1 changed file with 49 additions and 3 deletions.
52 changes: 49 additions & 3 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
cmake .. -DWITH_VIDEO_DECODING=On -DWITH_VIDEO_DEVICE=On -DWITH_OPENSLIDE_SUPPORT=On -DWITH_STB_IMAGE=On -DWITH_LIBSIXEL=On
make -k
AppImage:
AppImageBuild:
runs-on: ubuntu-latest
name: Build AppImage
steps:
Expand Down Expand Up @@ -118,8 +118,6 @@ jobs:
name: timg-${{ env.PACKAGE_VERSION }}-x86_64.AppImage
path: timg-${{ env.PACKAGE_VERSION }}-x86_64.AppImage

# TODO: upload to release

CodeFormatting:
if: false # currently, there is no clang-format-13 in ubuntu latest
runs-on: ubuntu-latest
Expand All @@ -137,3 +135,51 @@ jobs:
- name: Run formatting style check
run: ./.github/bin/run-clang-format.sh

TagAndRelease:
needs: [ AppImage ]
name: Version Tagging
runs-on: ubuntu-latest
#if: ${{github.event_name == 'push' && github.ref == 'refs/heads/main'}}
permissions:
contents: write

steps:
- name: 📥 Download artifacts
uses: actions/download-artifact@v3

- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Tag with CMake version if not already.
run: |
git config --local user.name "Development Bot"
git config --local user.email "[email protected]"
# We want to tag whenever the cmake version changes. So extract the
# hash of when the current version was entered.
read TAG_HASH TAG_VERSION <<<$(git annotate -l CMakeLists.txt | sed 's/\(^[0-9A-Fa-f]\+\).*project(timg VERSION \([0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1 \2/p;d')
echo "timg Version v${TAG_VERSION} at hash ${TAG_HASH}"
# If this is the first time we see this tag: apply.
if [ -z "$(git tag -l "v${TAG_VERSION}")" ]; then
git tag -a "v${TAG_VERSION}" ${TAG_HASH} -m "Update to v${TAG_VERSION}"
git push origin "v${TAG_VERSION}"
echo "RELEASE_TAG=v${TAG_VERSION}" >> $GITHUB_ENV
else
echo "Tag does exist already"
fi
- name: 🎉 Release If Tagged
if ${{ env.RELEASE_TAG != '' }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: artifact/timg-*.AppImage
tag: ${{ env.RELEASE_TAG }}
overwrite: true
file_glob: true
prerelease: true

0 comments on commit 75e46ff

Please sign in to comment.