Bumped version to 1.2.1 #3
Workflow file for this run
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
name: Create Release | |
on: | |
push: | |
tags: ['*'] | |
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=gm-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: startsWith(github.ref, 'refs/tags/') | |
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 |