-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from hanzi/github-action
Add a basic GitHub Actions workflow for releases
- Loading branch information
Showing
8 changed files
with
335 additions
and
218 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,38 @@ | ||
name: Creates a new release when a tag is pushed | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
create-release-for-tag: | ||
# This release action only really makes sense in the main repository and not in | ||
# a fork, hence this condition. | ||
if: github.repository == '40Cakes/pokebot-gen3' | ||
|
||
name: "Create a release for the tag" | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Update version.py and remove unnecessary files | ||
run: | | ||
echo "pokebot_name = \"PokéBot\"" > modules/version.py | ||
echo "pokebot_version = \"${{ github.ref_name }}\"" >> modules/version.py | ||
rm -rf .git .github .gitattributes .gitignore pokebot.spec | ||
mv LICENSE LICENSE.txt | ||
- name: Create a ZIP file | ||
run: | | ||
zip -qq -r /tmp/pokebot-${{ github.ref_name }}.zip . | ||
- name: Creates the GitHub release | ||
uses: marvinpinto/[email protected] | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
prerelease: false | ||
automatic_release_tag: ${{ github.ref_name }} | ||
files: | | ||
/tmp/pokebot-${{ github.ref_name }}.zip |
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
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
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
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 |
---|---|---|
@@ -1,2 +1,33 @@ | ||
# Note: This file will get replaced when run in GitHub actions. | ||
# In that case, the tagged version will be placed in here instead. | ||
# | ||
# So this file is only for development, or when someone just fetches | ||
# the Git repository. | ||
# | ||
# It will try to get the current commit hash and use it as the | ||
# version number, prefixed by `dev-` (e.g. `dev-a1b2c3d`.) | ||
|
||
import os | ||
from modules.runtime import get_base_path | ||
|
||
pokebot_name = "PokéBot" | ||
pokebot_version = "v0.0.3a" # TODO automatically append latest commit hash to version e.g. v0.0.1-e3fa5f5 | ||
pokebot_version = "dev" | ||
|
||
try: | ||
# If someone managed to get a copy of the repository without actually having | ||
# Git installed, this should still be able to get the commit hash of the current | ||
# HEAD. | ||
# It's probably not the _best_ way to do this... but it works. | ||
git_dir = get_base_path() / ".git" | ||
if git_dir.is_dir(): | ||
with open(git_dir / "HEAD", "r") as head_file: | ||
head = head_file.read().strip() | ||
if head.startswith("ref: "): | ||
full_path = git_dir.as_posix() + "/" + head[5:] | ||
with open(full_path, "r") as ref_file: | ||
ref = ref_file.read().strip() | ||
pokebot_version = f"dev-{ref[0:7]}" | ||
except: | ||
# If any issue occurred while trying to figure out the current commit hash, | ||
# just default to showing 'dev' for the version. | ||
pass |
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
Oops, something went wrong.