b2d/.github/workflows/release.yml
2020-05-31 19:53:38 -05:00

115 lines
3.4 KiB
YAML

name: Release Builds
on: push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build-and-store-artifact:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
steps:
- uses: actions/checkout@v1
- uses: ilammy/msvc-dev-cmd@v1
- name: Make GNU
if: matrix.os != 'windows-latest'
working-directory: ./src
run: make
shell: bash
- name: Make Windows
if: matrix.os == 'windows-latest'
working-directory: ./src
run: nmake
- name: Test
run: cd tests ; ./test.sh
- name: Upload binary artifact
if: matrix.os != 'windows-latest'
uses: actions/upload-artifact@v2
with:
name: ${{ format('binary-{0}', matrix.os) }}
path: b2d
- name: Upload binary artifact exe
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v2
with:
name: ${{ format('binary-{0}', matrix.os) }}
path: b2d.exe
create-release:
if: startsWith(github.ref, 'refs/tags/v')
name: Create Release
needs: build-and-store-artifact
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Create Release
id: create_release
uses: actions/create-release@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Debug dump
env:
UPLOAD_URL: ${{ toJson( steps.create_release.outputs.upload_url )}}
run: |
echo "$UPLOAD_URL" > release_url.txt
echo "UPLOAD_URL= $UPLOAD_URL"
- name: Upload URL for later use
uses: actions/upload-artifact@v2
with:
name: data
path: release_url.txt
package-and-upload:
name: Package and Upload
needs: create-release
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
steps:
- uses: actions/checkout@v1
- name: Download Release Data
uses: actions/download-artifact@v1
with:
name: data
- name: Get Tag Name
id: get_data
shell: bash
run: |
URL=`cat data/release_url.txt | tr -d '"'`
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
echo ::set-output name=RELEASE_URL::$URL
echo "URL = $URL"
echo name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
- name: Download Release Binary
uses: actions/download-artifact@v1
with:
name: ${{ format('binary-{0}', matrix.os) }}
- name: Package NIX
if: matrix.os != 'windows-latest'
run: |
zip --junk-paths b2d.zip ${{ format('binary-{0}/b2d', matrix.os) }} README.md
- name: Package WIN
if: matrix.os == 'windows-latest'
run: |
7z.exe a b2d.zip ${{ format('./binary-{0}/b2d.exe', matrix.os) }} README.md
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_data.outputs.RELEASE_URL }}
asset_path: ./b2d.zip
asset_name: ${{ format('b2d-{0}-{1}.zip', matrix.os, steps.get_data.outputs.SOURCE_TAG ) }}
asset_content_type: application/zip