diff --git a/.github/changelog_conf.json b/.github/changelog_conf.json new file mode 100644 index 0000000000..e4c7eab9b1 --- /dev/null +++ b/.github/changelog_conf.json @@ -0,0 +1,4 @@ +{ + "template": "${{UNCATEGORIZED}}", + "pr_template": "- ${{TITLE}}\n" +} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000..dd30dbb1db --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,100 @@ +name: build + +on: + push: + branches: + - master + tags: + - "v*" + pull_request: + +jobs: + prepare-release: + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + steps: + - name: Clone project + uses: actions/checkout@v2 + + - name: Build changelog + id: build_changelog + uses: mikepenz/release-changelog-builder-action@v1 + with: + configuration: .github/changelog_conf.json + failOnError: true + ignorePreReleases: true + commitMode: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create release + uses: softprops/action-gh-release@v1 + with: + body: ${{ steps.build_changelog.outputs.changelog }} + files: | + LICENSE + fail_on_unmatched_files: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + build: + name: build-${{ matrix.os }} + if: always() + needs: prepare-release + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-20.04 + cache_path: ~/.stack + stack_args: "--test" + artifact_rel_path: /bin/dog-food + asset_name: dog-food-ubuntu-20_04-x86-64 + - os: ubuntu-18.04 + cache_path: ~/.stack + stack_args: "--test" + artifact_rel_path: /bin/dog-food + asset_name: dog-food-ubuntu-18_04-x86-64 + - os: macos-latest + cache_path: ~/.stack + stack_args: "--test" + artifact_rel_path: /bin/dog-food + asset_name: dog-food-macos-x86-64 + # TODO enable tests for windows once fixed (remove stack_args altogether) + - os: windows-latest + cache_path: C:/sr + stack_args: "" + artifact_rel_path: /bin/dog-food.exe + asset_name: dog-food-windows-x86-64 + steps: + - name: Clone project + uses: actions/checkout@v2 + + - name: Setup Stack + uses: haskell/actions/setup@v1 + with: + ghc-version: '8.8.4' + enable-stack: true + stack-version: 'latest' + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ matrix.cache_path }} + key: ${{ matrix.os }}-${{ hashFiles('stack.yaml') }} + + - name: Build & test + id: build_test + run: | + stack build ${{ matrix.stack_args }} + echo "::set-output name=LOCAL_INSTALL_ROOT::$(stack path --local-install-root)" + + - name: Upload binaries to release + if: startsWith(github.ref, 'refs/tags/v') + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ${{ steps.build_test.outputs.LOCAL_INSTALL_ROOT }}${{ matrix.artifact_rel_path }} + asset_name: ${{ matrix.asset_name }} + tag: ${{ github.ref }}