-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added github workflow that automatically creates a release when a tag…
… is pushed
- Loading branch information
1 parent
0aa81b9
commit 52c717c
Showing
1 changed file
with
55 additions
and
0 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 |
---|---|---|
@@ -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 |