Build changes. #198
Workflow file for this run
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
name: Github Action Docker Image | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
release: | |
types: [prereleased] | |
jobs: | |
# check-formatting: | |
# name: Check Haskell formatting | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v2 | |
# | |
# - name: Common setup | |
# uses: ./.github/actions/common_setup | |
# with: | |
# authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} | |
# | |
# - name: Run fourmolu | |
# run: | | |
# nix-shell nix/ci.nix -j auto --run "git ls-files '*.hs' | xargs fourmolu -m inplace -o -XRecursiveDo -o -XTypeApplications -o -XPatternSynonyms -o -XBangPatterns" | |
# git diff --exit-code | |
check_versions: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
submodules: recursive | |
- name: Check library version | |
if: github.event_name == 'release' | |
run: | | |
if [ "$(awk -F ':' '/^version/ {gsub(/ /, "", $2); print $2}' compaREST.cabal)" != "${{ github.event.release.tag_name }}" ]; then | |
echo "::error file=compaREST.cabal::Library version does not match release version." | |
exit 1 | |
fi | |
- name: Check docker tag | |
if: github.event_name == 'release' | |
run: | | |
if [ "$(yq eval '.runs.image' action.yaml | awk -F ':' '{print $NF}')" != "${{ github.event.release.tag_name }}" ]; then | |
echo "::error file=action.yaml::Action docker tag does not match release tag." | |
exit 1 | |
fi | |
- name: Check changelog | |
if: github.event_name == 'release' | |
run: | | |
if ! grep '^## ${{ github.event.release.tag_name }}$' CHANGELOG.md; then | |
echo "::error file=CHANGELOG.md::CHANGELOG.md does not contain an entry for this release." | |
exit 1 | |
fi | |
Linux: | |
needs: check_versions | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
submodules: recursive | |
- name: Common setup | |
uses: ./.github/actions/common_setup | |
with: | |
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} | |
- name: Test | |
shell: bash | |
run: | | |
$(nix-build -A test -j auto --no-out-link)/bin/compaREST-tests | |
- name: Build Linux static binary | |
shell: bash | |
run: | | |
cp $(nix-build -A compaRESTStaticBin -j auto --no-out-link)/bin/compaREST compaREST | |
- name: Upload compaREST Linux Binary | |
uses: actions/upload-artifact@v2 | |
with: | |
name: compaREST-Linux | |
path: compaREST | |
- name: Build Docker Images | |
shell: bash | |
run: | | |
cp $(nix-build -A compaRESTGithubAction -j auto --no-out-link) compaREST-Github-Action-image.tar.gz | |
cp $(nix-build -A compaRESTImage -j auto --no-out-link) compaREST-image.tar.gz | |
- name: Upload compaREST Docker Github Action Image | |
uses: actions/upload-artifact@v2 | |
with: | |
name: compaREST Github Action Docker Image | |
path: compaREST-Github-Action-image.tar.gz | |
- name: Upload compaREST Docker Image | |
uses: actions/upload-artifact@v2 | |
with: | |
name: compaREST Docker Image | |
path: compaREST-image.tar.gz | |
- name: Login to DockerHub | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Push Nightly Docker Images to DockerHub | |
if: github.ref == 'refs/heads/master' && github.event_name == 'push' | |
shell: bash | |
run: | | |
skopeo copy docker-archive:$(nix-build -A compaRESTGithubAction -j auto --no-out-link) docker://typeable/comparest-github-action:nightly | |
skopeo copy docker-archive:$(nix-build -A compaRESTImage -j auto --no-out-link) docker://typeable/comparest:nightly | |
- name: Push Release Docker Images to DockerHub | |
if: github.event_name == 'release' | |
shell: bash | |
run: | | |
skopeo copy docker-archive:$(nix-build -A compaRESTGithubAction -j auto --no-out-link) docker://typeable/comparest-github-action:${{ github.event.release.tag_name }} | |
skopeo copy docker-archive:$(nix-build -A compaRESTImage -j auto --no-out-link) docker://typeable/comparest:${{ github.event.release.tag_name }} | |
- name: Zip Release Assets | |
if: github.event_name == 'release' | |
shell: bash | |
run: | | |
zip compaREST-Linux-x86.zip compaREST | |
- name: Upload compaREST Github Action Docker Image to release | |
if: github.event_name == 'release' | |
uses: svenstaro/[email protected] | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: compaREST-Github-Action-image.tar.gz | |
tag: ${{ github.ref }} | |
- name: Upload compaREST Docker Image to release | |
if: github.event_name == 'release' | |
uses: svenstaro/[email protected] | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: compaREST-image.tar.gz | |
tag: ${{ github.ref }} | |
- name: Upload compaREST binary – Linux – x86 to release | |
if: github.event_name == 'release' | |
uses: svenstaro/[email protected] | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: compaREST-Linux-x86.zip | |
tag: ${{ github.ref }} | |
dist: | |
needs: check_versions | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
submodules: recursive | |
- name: Cache | |
uses: actions/cache@v1 | |
with: | |
path: | | |
~/.stack | |
.stack-work | |
key: ${{ runner.os }}-stack-${{ hashFiles('stack.yaml') }}-${{ hashFiles('**.cabal') }} | |
restore-keys: | | |
${{ runner.os }}-stack-${{ hashFiles('stack.yaml') }} | |
${{ runner.os }}-stack | |
- name: Upgrade stack | |
shell: bash | |
# Needed for Hackage token authorization | |
run: stack upgrade --git | |
- name: Build dist | |
run: | | |
stack sdist --pvp-bounds both --test-tarball | |
echo "distPath=$(stack path | awk -F ": " '/dist-dir/ {print $2}')" >> $GITHUB_ENV | |
- name: Upload compaREST sources artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: compaREST sources | |
path: ${{ env.distPath }}/*.tar.gz | |
- name: Upload compaREST sources to release | |
if: github.event_name == 'release' | |
uses: svenstaro/[email protected] | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file_glob: true | |
file: ${{ env.distPath }}/*.tar.gz | |
tag: ${{ github.ref }} | |
- name: Publish compaREST candidate to Hackage | |
shell: bash | |
if: github.event_name == 'release' | |
env: | |
HACKAGE_KEY: ${{ secrets.HACKAGE_KEY }} | |
run: | | |
stack upload --pvp-bounds both --test-tarball --candidate . | |
macOS: | |
needs: check_versions | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
submodules: recursive | |
- name: Common setup | |
uses: ./.github/actions/common_setup | |
with: | |
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} | |
- name: Build macOS binary bundle | |
run: | | |
cp -LR $(nix-build -A macOSCompaRESTBundle -j auto --no-out-link) compaREST | |
- name: Upload macOS compaREST bundle | |
uses: actions/upload-artifact@v2 | |
with: | |
name: compaREST binary – macOS – x86 | |
path: compaREST | |
- name: Zip Release Assets | |
if: github.event_name == 'release' | |
shell: bash | |
run: | | |
zip -r compaREST-macOS-x86.zip compaREST | |
- name: Upload compaREST binary – macOS – x86 to release | |
if: github.event_name == 'release' | |
uses: svenstaro/[email protected] | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: compaREST-macOS-x86.zip | |
tag: ${{ github.ref }} | |
Linux-Windows: | |
needs: check_versions | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
submodules: recursive | |
- name: Common setup | |
uses: ./.github/actions/common_setup | |
with: | |
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} | |
- name: Build Windows binary | |
run: | | |
cp -LR $(nix-build -A WindowsCompaRESTBin -j auto --no-out-link)/bin compaREST | |
- name: Upload Windows compaREST bundle | |
uses: actions/upload-artifact@v2 | |
with: | |
name: compaREST binary – Windows | |
path: compaREST | |
- name: Zip Release Assets | |
if: github.event_name == 'release' | |
shell: bash | |
run: | | |
zip -r compaREST-Windows.zip compaREST | |
- name: Upload compaREST binary – Windows to release | |
if: github.event_name == 'release' | |
uses: svenstaro/[email protected] | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: compaREST-Windows.zip | |
tag: ${{ github.ref }} |