Skip to content

Commit

Permalink
actions: add CD
Browse files Browse the repository at this point in the history
  • Loading branch information
maxb2 committed May 18, 2020
1 parent 7e7688f commit 5f5a9bb
Showing 1 changed file with 122 additions and 0 deletions.
122 changes: 122 additions & 0 deletions .github/workflows/build-executables.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Build Executables

on:
push:
tags:
- "v*"

jobs:

job_build:
name: ${{ matrix.os }} Binaries
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
os: [ubuntu, macos, windows]
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyinstaller
pip install -r requirements.txt
- name: Build Executable
run: |
mkdir ${{ matrix.os }}
cd donjon_painter
python -O -m PyInstaller --clean --onefile --name donjon-painter --distpath ../${{ matrix.os }} painter.py
- name: Package Executable
run: |
mv ./LICENSE ./${{ matrix.os }}
mv ./README.rst ./${{ matrix.os }}
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.os }}
path: ${{ matrix.os }}


job_upload:
name: Upload Release Assets
needs: job_build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

# Github Actions is weird about environment variables.
# Setting a variable in this way makes it available to all subsequent steps in the job.
# The only way to get the tag is to extract it from github-ref.
# For example, GITHUB_REF='refs/tags/v1.5'.
- name: Set environment
run: |
export TAG="${GITHUB_REF#'refs/tags/'}"
echo "::set-env name=GH_TAG::$TAG"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: true
prerelease: false

- uses: actions/download-artifact@v2
with:
path: bin/

# Zip all artifacts
- name: Zip Archives
run: |
cd bin
chmod +x ./macos/donjon-painter
chmod +x ./ubuntu/donjon-painter
for idir in */;
do
(cd "$idir" && zip -r "../${idir%/}.zip" .);
done
# We have to upload assets individually using upload-release-asset@v1
# There isn't a matrix for steps.
- name: Upload Linux Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./bin/ubuntu.zip
asset_name: donjon-painter-linux-${{ env.GH_TAG }}.zip
asset_content_type: application/zip

- name: Upload MacOS Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./bin/macos.zip
asset_name: donjon-painter-macos-${{ env.GH_TAG }}.zip
asset_content_type: application/zip

- name: Upload Windows Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./bin/windows.zip
asset_name: donjon-painter-windows-${{ env.GH_TAG }}.zip
asset_content_type: application/zip

0 comments on commit 5f5a9bb

Please sign in to comment.