Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CI to publish binary releases on git version tag #27

Merged
merged 14 commits into from
May 23, 2020
184 changes: 140 additions & 44 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,30 @@ on:
branches-ignore: [ staging.tmp ]

jobs:
build:

# Prepare a file containing the commit sha, to be included in the releases
prepare:
name: Prepare for builds
runs-on: ubuntu-18.04
steps:
- name: Create commit-sha file
env:
GITHUB_SHA: ${{ github.sha }}
run: |
echo $GITHUB_SHA > commit-sha
- name: Publish commit-sha
uses: actions/upload-artifact@v2
with:
path: commit-sha
name: dist
Copy link
Contributor

@Korijn Korijn May 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unlike wgpu-bin where we have to clone the source repo prior to building, here you can just create the commit-sha file in the final publish job and avoid the prepare job completely. It will allow queueing the subsequent jobs earlier

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd assumed the build needed it, but make package already does that. We can thus omit this step completely, because the GH release page already reports the commit sha :)


# Builds to test that the package can be build on various platforms
test-build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
name: [
MacOS Stable,
MacOS Nightly,
Ubuntu Stable,
Ubuntu Nightly,
Windows Stable,
Windows Nightly
]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this, as it's not needed, I believe.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out this was here for bors, see bors.toml :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it though? The jobs still have the same names. I don't think Bors checks this file or anything, it just listens for success/fail events with matching names, so I think it's fine. Unless I'm missing something.

include:
- os: macos-10.15
name: MacOS Stable
Expand Down Expand Up @@ -96,43 +106,97 @@ jobs:
run: cargo +nightly install cbindgen
- run: ${{ matrix.make_command }}
shell: bash
- if: matrix.channel == 'stable' && contains(github.ref, 'tags/v')
uses: actions/upload-artifact@v2
with:
name: artifact
path: dist/wgpu-*.zip

publish:
if: contains(github.ref, 'tags/v')
needs: [build]
name: Publish release artifacts
runs-on: ubuntu-18.04
# Builds for binary releases.
# Also build on non-tag commits; it also functions as a test.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have an idea of how much slower this would make our general CI? I.e. does using an image affect the build times?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd slightly prefer to only bother building tagged commits to avoid the potential for CI backlog, but we could start with this and see how it goes

# The Linux builds are performed on a "manylinux2010" container. This container
# is designed such that that the resulting binary has minimal dependencies on system
# libraries, and thus works on as many linuxes as possible. It's a thing from the
# Python world, but generally useful.
release-build:
needs: prepare
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- name: Linux-64
os: ubuntu-18.04
RUST_TOOLCHAIN: stable
ARCH: 64
OS_NAME: linux
IMAGE: manylinux2010_x86_64
- name: Linux-32
os: ubuntu-18.04
RUST_TOOLCHAIN: stable-i686-unknown-linux-gnu
ARCH: 32
OS_NAME: linux
IMAGE: manylinux2010_i686
- name: MacOS-64
os: macOS-10.14
RUST_TOOLCHAIN: stable
ARCH: 64
OS_NAME: macos
MACOSX_DEPLOYMENT_TARGET: '10.13'
- name: Windows-64
os: vs2017-win2016
RUST_TOOLCHAIN: stable-msvc
ARCH: 64
OS_NAME: windows
- name: Windows-32
os: vs2017-win2016
RUST_TOOLCHAIN: stable-i686-pc-windows-msvc
ARCH: 32
OS_NAME: windows
steps:
- name: Download Artifacts
uses: actions/download-artifact@v2
with:
name: artifact
path: $GITHUB_WORKSPACE/wgpu-release/
- 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 }}
# TODO
body:
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
# Move back to official action after fix https://github.com/actions/upload-release-asset/issues/4
uses: csexton/release-asset-action@v2
with:
pattern: "$GITHUB_WORKSPACE/wgpu-release/*.zip"
release-url: ${{ steps.create_release.outputs.upload_url }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2
- name: Docker build
if: success() && matrix.OS_NAME == 'Linux'
env:
IMAGE: ${{ matrix.IMAGE }}
RUST_TOOLCHAIN: ${{ matrix.RUST_TOOLCHAIN }}
run: |
CID=$(docker create -t -w /tmp/wgpu-native -v $PWD:/tmp/src:ro quay.io/pypa/$IMAGE bash -c "\
Copy link
Contributor

@Korijn Korijn May 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you need to preface all of the bash scripts with set -ex to make sure we don't steamroll errors? Or is that by default on github actions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default is set -e (-like behavior), which can be turned off with fail-fast: false

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that's fine then

cp -r /tmp/src/. . && \
rm -rf ./dist && \
export PATH=/root/.cargo/bin:\$PATH && \
export USER=root && \
curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none && \
rustup toolchain install --no-self-update $RUST_TOOLCHAIN && \
rustup default $RUST_TOOLCHAIN && \
yum install zip -y && \
make package")
docker start -ai $CID
mkdir -p dist
docker cp $CID:/tmp/wgpu-native/dist/. dist/.
docker rm $CID
- name: Host build
if: success() && matrix.OS_NAME != 'Linux'
env:
RUST_TOOLCHAIN: ${{ matrix.RUST_TOOLCHAIN }}
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.MACOSX_DEPLOYMENT_TARGET }}
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --default-toolchain none
export PATH=$HOME/.cargo/bin:$PATH
rustup toolchain install --no-self-update $RUST_TOOLCHAIN
rustup default $RUST_TOOLCHAIN
make package
shell: bash
- name: Pre-publish
env:
OS_NAME: ${{ matrix.OS_NAME }}
ARCH: ${{ matrix.ARCH }}
run: |
mkdir -p ./dist
mv dist/*debug*.zip ./dist/wgpu-$OS_NAME-$ARCH-debug.zip
mv dist/*release*.zip ./dist/wgpu-$OS_NAME-$ARCH-release.zip
shell: bash
- name: Publish
uses: actions/upload-artifact@v2
with:
path: dist
name: dist

# Some smaller test builds

ios-build:
name: iOS Stable
Expand Down Expand Up @@ -166,3 +230,35 @@ jobs:
- uses: actions/checkout@v2
- run: rustup component add clippy
- run: cargo clippy --features vulkan-portability

# Create a Github release and upload the binary libs that we just built.
# There should be a release and debug build for each os (win32, win64, MacOS, Linux),
# plus a file containing the commit sha.
publish:
needs: [release-build]
runs-on: ubuntu-18.04
if: success() && github.event_name == 'tag'
steps:
- uses: actions/checkout@v2
- name: Download assets
uses: actions/[email protected]
with:
name: dist
- name: Create release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
Autogenerated binary modules.
draft: false
prerelease: false
- name: Upload Release Assets
# Move back to official action after fix https://github.com/actions/upload-release-asset/issues/4
uses: AButler/[email protected]
with:
release-tag: ${{ github.ref }}
files: 'dist/*.zip;dist/commit-sha'
repo-token: ${{ secrets.GITHUB_TOKEN }}