Skip to content

Commit

Permalink
Added github workflow that automatically creates a release when a tag…
Browse files Browse the repository at this point in the history
… is pushed
  • Loading branch information
PhilInTheGaps committed Nov 11, 2023
1 parent 0aa81b9 commit 52c717c
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/create_release.yml
@@ -0,0 +1,55 @@
name: Create Release

on:
push:
tags: ['*']
branches:
- master
release:
types: [published]
pull_request:
paths: [.github/workflows/create_release.yml]

jobs:
release:
if: ${{ github.repository == 'PhilInTheGaps/GM-Companion' }}
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Fake name for PRs
if: ${{ github.event_name == 'pull_request' }}
run: echo "GM_GITHUB_REF=refs/tags/pr-tag" >> "$GITHUB_ENV"
- name: Real name for non-PRs
if: ${{ github.event_name != 'pull_request' }}
run: echo "GM_GITHUB_REF=$GITHUB_REF" >> "$GITHUB_ENV"
- name: Set filenames
run: |
tag_or_branch="${GM_GITHUB_REF#refs/tags/}"
tag_or_branch="${tag_or_branch#refs/heads/}"
echo "GM_RELEASE_NAME=gm-companion_$tag_or_branch" >> "$GITHUB_ENV"
echo "GM_RELEASE_FILE=companion_$tag_or_branch.tar.gz" >> "$GITHUB_ENV"
- name: Create source distribution
run: |
# Create new folder with specified name so extracting the archive yields that
rm -rf "/tmp/$GM_RELEASE_NAME"
cp -r "$PWD" "/tmp/$GM_RELEASE_NAME"
mv "/tmp/$GM_RELEASE_NAME" .
# Cleanup
rm -rf "$GM_RELEASE_NAME"/{.circleci,.ci}
find "$GM_RELEASE_NAME" -name '.git*' -exec rm -rv {} \; || true
# Create archive
tar -czf "$GM_RELEASE_FILE" "$GM_RELEASE_NAME"
echo "Created source archive $GM_RELEASE_FILE with content: $(ls -a "$GM_RELEASE_NAME")"
- name: Upload source distribution
if: ${{ github.event_name == 'release' }}
uses: softprops/action-gh-release@v1
with:
files: ${{env.GM_RELEASE_FILE}}

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}
cancel-in-progress: true

0 comments on commit 52c717c

Please sign in to comment.