Skip to content

build

build #67

Workflow file for this run

name: build
on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
create:
tags:
- v*
jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
max-parallel: 5
matrix:
platform: [
android-arm, android-arm64, android-x64, android-x86,
linux-armv7, linux-arm64, linux-x64, linux-x86,
windows-x64, windows-x86, darwin-x64 ]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build ${{ matrix.platform }} docker image
run: make env PLATFORM=${{ matrix.platform }}
- name: Build libtorrent-go ${{ matrix.platform }}
run: |
mkdir build
make ${{ matrix.platform }} GOPATH="$(readlink -f build)"
- name: Generate libtorrent-go ${{ matrix.platform }} zip
id: generate_zip
run: |
pkg_path="build/pkg"
cd "${pkg_path}"
folder_name=$(ls -d1 *)
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
classifier=$(sed -E 's|^refs/tags/v?||' <<<"${{ github.ref }}")
else
classifier=$(git rev-parse --short HEAD)
fi
asset_name="libtorrent-go.${classifier}.${folder_name}.zip"
zip -9 -r "${asset_name}" "${folder_name}"
echo "::set-output name=asset_path::${pkg_path}/${asset_name}"
echo "::set-output name=asset_name::${asset_name}"
- name: Upload ${{ matrix.platform }} zip
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.platform }}
path: ${{ steps.generate_zip.outputs.asset_path }}
- name: Push ${{ matrix.platform }} docker image
if: success() && github.event_name == 'create' && startsWith(github.ref, 'refs/tags/')
run: |
docker login -u="${{ secrets.DOCKER_USERNAME }}" -p="${{ secrets.DOCKER_PASSWORD }}"
make push PLATFORM=${{ matrix.platform }}
release:
name: Release
runs-on: ubuntu-latest
needs: build
if: success() && github.event_name == 'create' && startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get all artifacts
uses: actions/[email protected]
with:
path: artifacts
- name: Perform release
run: |
assets=()
for asset in artifacts/*/*.zip; do
assets+=("-a" "${asset}")
done
git_tag="$(sed 's|refs/tags/||' <<< "${{ github.ref }}")"
hub release create "${assets[@]}" -m "${git_tag}" "${git_tag}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}