Skip to content

feat: reset deployment between tests #119

feat: reset deployment between tests

feat: reset deployment between tests #119

Workflow file for this run

name: main
env:
LANG: C.UTF-8
GH_TOKEN: ${{ github.token }}
on:
push:
branches: main
pull_request:
branches: main
permissions:
contents: write
packages: write
jobs:
build-and-test:
name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04]
platform: ['x86_64-linux']
ghc-version: ['9.6.6']
cabal-version: ['3.12.1.0']
steps:
- uses: actions/checkout@v4
# Following https://github.com/docker/build-push-action?tab=readme-ov-file#usage
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
## - name: Cache
## uses: actions/cache@v4
## id: cache
## with:
## path: |
## root-local-state-cabal-store
## root-cache-cabal
## dist-newstyle
## key: ${{ runner.os }}-ghc-${{ matrix.ghc-version }}
## # XXX: key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }} ?
## - name: Inject cache into docker
## uses: reproducible-containers/buildkit-cache-dance@v3.1.0
## with:
## cache-map: |
## {
## "root-local-state-cabal-store": "/root/.local/state/cabal/store",
## "root-cache-cabal": "/root/.cache/cabal",
## "dist-newstyle": "dist-newstyle"
## }
## skip-extraction: ${{ steps.cache.outputs.cache-hit }}
- name: Build and test
uses: docker/build-push-action@v6
with:
context: .
pull: true
# XXX: don't push feature branches either?
push: ${{ github.event_name != 'pull_request' }} # Don't push on PRs.
file: Dockerfile
tags: |
ghcr.io/spex-lang/spex-build:${{ github.ref_name }}
ghcr.io/spex-lang/spex-build:latest
# We pass in the version as a secret, since they don't affect the
# container caching, this will be picked up and used by --version.
# https://docs.docker.com/build/building/secrets/
secrets: version=${{ github.sha }}
# https://docs.docker.com/build/ci/github-actions/cache/#github-cache
# https://docs.docker.com/build/ci/github-actions/cache/#cache-mounts
cache-from: type=registry,ref=ghcr.io/spex-lang/spex-build:buildcache
cache-to: type=registry,ref=ghcr.io/spex-lang/spex-build:buildcache,mode=max
- name: Create new git tag, if merge to main and .cabal version is bumped
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: sol/haskell-autotag@v1
id: autotag
- name: Build static binaries
if: steps.autotag.outputs.created
uses: docker/build-push-action@v6
with:
context: .
pull: true
push: ${{ github.event_name != 'pull_request' }} # Don't push on PRs.
file: release/Dockerfile
tags: |
ghcr.io/spex-lang/spex:${{ github.ref_name }}
ghcr.io/spex-lang/spex:latest
outputs: type=local,dest=${{ github.workspace }}/bin/
# https://docs.docker.com/build/ci/github-actions/cache/#github-cache
cache-from: type=registry,ref=ghcr.io/spex-lang/spex:buildcache
cache-to: type=registry,ref=ghcr.io/spex-lang/spex:buildcache,mode=max
- name: Release
if: steps.autotag.outputs.created
run: |
ls -R bin/
find bin/ -maxdepth 1 -type f -executable -exec \
mv {} "{}-${{ steps.autotag.outputs.version }}-${{ matrix.platform }}" \;
gh release create --draft --notes-file=CHANGELOG.md \
"v${{ steps.autotag.outputs.version }}" ${{ github.workspace }}/bin/*