diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 1962c9c..0b56ab8 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -8,17 +8,21 @@ on: push: branches: - main + tags: + - "v*" pull_request: jobs: build: + environment: cabal-cache + runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: ghc: ["8.10.4"] - os: [ubuntu-latest] + os: [ubuntu-latest, macos-latest] steps: - uses: actions/checkout@v2 @@ -29,9 +33,10 @@ jobs: ghc-version: ${{ matrix.ghc }} cabal-version: 3.4.0.0 - - name: Set some window specific things - if: matrix.os == 'windows-latest' - run: echo 'EXE_EXT=.exe' >> $GITHUB_ENV + - name: Cache configuration + run: | + echo "GIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + echo "CACHE_VERSION=3oqhaby" >> $GITHUB_ENV - name: Configure project run: cabal configure --enable-tests --enable-benchmarks --write-ghc-environment-files=ghc8.4.4+ @@ -40,22 +45,93 @@ jobs: run: | cat ${{ env.PLAN_JSON }} | jq -r '."install-plan"[].id' | sort | uniq > dependencies.txt - - uses: actions/cache@v2 - name: Cache cabal store + - name: Restore cabal cache + uses: haskell-works/cabal-cache-action@v1 + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + BINARY_CACHE_THREADS: ${{ secrets.BINARY_CACHE_THREADS }} + BINARY_CACHE_REGION: ${{ secrets.BINARY_CACHE_REGION }} + BINARY_CACHE_URI: ${{ secrets.BINARY_CACHE_URI }} + with: + args: | + sync-from-archive \ + --threads "$BINARY_CACHE_THREADS" \ + --archive-uri "$BINARY_CACHE_URI" \ + --region "$BINARY_CACHE_REGION" \ + --store-path "${{ steps.setup-haskell.outputs.cabal-store }}" + + - name: Build dependencies + run: cabal build --dependencies-only --enable-tests --enable-benchmarks --write-ghc-environment-files=ghc8.4.4+ + + - name: Save cabal cache + uses: haskell-works/cabal-cache-action@v1 + if: ${{ always() }} + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + BINARY_CACHE_THREADS: ${{ secrets.BINARY_CACHE_THREADS }} + BINARY_CACHE_REGION: ${{ secrets.BINARY_CACHE_REGION }} + BINARY_CACHE_URI: ${{ secrets.BINARY_CACHE_URI }} with: - path: ${{ steps.setup-haskell.outputs.cabal-store }} - key: cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}-${{ env.GITHUB_SHA }} - restore-keys: | - cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}-${{ env.GITHUB_SHA }} - cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }} - cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}- + args: | + sync-to-archive \ + --threads "$BINARY_CACHE_THREADS" \ + --archive-uri "$BINARY_CACHE_URI" \ + --region "$BINARY_CACHE_REGION" \ + --store-path "${{ steps.setup-haskell.outputs.cabal-store }}" - name: Build run: cabal build all --enable-tests --enable-benchmarks --write-ghc-environment-files=ghc8.4.4+ + - name: Save cabal cache + uses: haskell-works/cabal-cache-action@v1 + if: ${{ always() }} + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + BINARY_CACHE_THREADS: ${{ secrets.BINARY_CACHE_THREADS }} + BINARY_CACHE_REGION: ${{ secrets.BINARY_CACHE_REGION }} + BINARY_CACHE_URI: ${{ secrets.BINARY_CACHE_URI }} + with: + args: | + sync-to-archive \ + --threads "$BINARY_CACHE_THREADS" \ + --archive-uri "$BINARY_CACHE_URI" \ + --region "$BINARY_CACHE_REGION" \ + --store-path "${{ steps.setup-haskell.outputs.cabal-store }}" + - name: Test run: cabal test all --enable-tests --enable-benchmarks --write-ghc-environment-files=ghc8.4.4+ + - name: Compress Binary + id: compress_binary + env: + GHC_VER: ${{ matrix.ghc }} + run: | + cat dist-newstyle/cache/plan.json | jq -r ' + ."install-plan"[] + | select(."component-name") + | select(.style == "local") + | select(."component-name" | startswith("exe:")) + | ."bin-file"' > release-files.txt + + mkdir -p artifacts + + echo "Publishing the following files:" + + while IFS= read -r line; do + echo " $line" + cp "$line" artifacts + done < release-files.txt + + tar zcvf artifacts-${{ runner.OS }}-${{ matrix.ghc }}.tar.gz artifacts + + - uses: actions/upload-artifact@v2 + with: + name: artifacts-${{ runner.OS }}-${{ matrix.ghc }}.tar.gz + path: artifacts-${{ runner.OS }}-${{ matrix.ghc }}.tar.gz + check: needs: build runs-on: ubuntu-latest @@ -77,10 +153,6 @@ jobs: - name: Tag new version id: tag if: ${{ github.ref == 'refs/heads/main' }} - env: - server: http://hackage.haskell.org - username: ${{ secrets.HACKAGE_USER }} - password: ${{ secrets.HACKAGE_PASS }} run: | package_version="$(cat *.cabal | grep '^version:' | cut -d : -f 2 | xargs)" @@ -98,10 +170,18 @@ jobs: fi fi + - name: Show tag + run: | + echo "Ref: ${{ github.ref }}" + echo "Tag: ${{ steps.tag.outputs.tag }}" + + release: needs: [build, check] runs-on: ubuntu-latest + if: ${{ needs.check.outputs.tag != '' }} + outputs: upload_url: ${{ steps.create_release.outputs.upload_url }} @@ -116,3 +196,77 @@ jobs: cd $PROJECT_DIR && cd `dirname $i` cabal v2-sdist -o $PROJECT_DIR/build/sdist done; + + - name: Generate Changelog + run: | + git fetch --unshallow + + if git describe --tags 'HEAD^' --abbrev=0 > last-tag; then + git log --no-merges --format="%C(auto) %h %s" "$(cat last-tag)..HEAD" + else + git log --no-merges --format="%C(auto) %h %s" + fi > changelog.txt + + cat changelog.txt + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: ${{ needs.check.outputs.tag }} + release_name: Release ${{ needs.check.outputs.tag }} + draft: false + prerelease: false + body_path: changelog.txt + + publish: + needs: [build, release] + + runs-on: ${{ matrix.os }} + + if: ${{ needs.check.outputs.tag != '' }} + + strategy: + fail-fast: false + matrix: + ghc: ["8.10.4"] + os: [ubuntu-latest, macos-latest] + + steps: + - uses: actions/download-artifact@v2 + id: download_artifact + with: + name: artifacts-${{ runner.OS }}-${{ matrix.ghc }}.tar.gz + path: . + + - name: Compute axes + id: axes + run: | + case ${{ matrix.os }} in + ubuntu-*) os="linux" ;; + macos-*) os="darwin" ;; + windows-*) os="windows" ;; + *) exit 1 ;; # error + esac + arch_os="$(uname -m)-$os" + echo "::set-output name=arch_os::$arch_os" + + - name: Upload Artifacts to Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + files: artifacts-${{ runner.OS }}-${{ matrix.ghc }}.tar.gz + + - name: Upload Artifacts to Release + uses: actions/upload-release-asset@v1.0.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.release.outputs.upload_url }} + asset_path: artifacts-${{ runner.OS }}-${{ matrix.ghc }}.tar.gz + asset_name: artifacts-${{ runner.OS }}-${{ matrix.ghc }}.tar.gz + asset_content_type: application/tar+gzip diff --git a/changelog.txt b/changelog.txt new file mode 100644 index 0000000..48d161b --- /dev/null +++ b/changelog.txt @@ -0,0 +1,12 @@ + 9b65457 Remove unused credentials. Cache configuration. Fix releases. + e1d3dd3 Also add selenium-server-standalone to readme + ff734f9 Fix date selection in gis + be12e7a Fix dayInWeekCsvFile + 59f0152 Add --date, --headless, and --exit-delay options. + 29eca45 Unused imports + 6b42a72 Adjust bounds + 49d6300 Add entropy from geol-uoa + 5b8bac8 Commands to download and hash NYSE and GIS data + 2067a94 Initial main + a8390ea Initial project + db53b90 Initial commit diff --git a/last-tag b/last-tag new file mode 100644 index 0000000..e69de29