diff --git a/.github/workflows/actionlint.yml b/.github/workflows/actionlint.yml new file mode 100644 index 0000000..05584a7 --- /dev/null +++ b/.github/workflows/actionlint.yml @@ -0,0 +1,36 @@ +name: Lint workflows + +on: + push: + branches: [ main, dev ] + paths: + - .github/workflows/** + pull_request: + branches: [ main, dev ] + paths: + - .github/workflows/** + workflow_dispatch: + +permissions: + contents: read + +jobs: + actionlint: + runs-on: ubuntu-latest + env: + ACTIONLINT_VERSION: '1.7.12' + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + # Script and binary are both pinned to the same release so a new + # actionlint version can't change the rules without a reviewed bump. + # shellcheck is preinstalled on the runner, so `run:` blocks are + # checked too. + - name: Download actionlint + id: get_actionlint + run: bash <(curl -fsSL "https://raw.githubusercontent.com/rhysd/actionlint/v${ACTIONLINT_VERSION}/scripts/download-actionlint.bash") "${ACTIONLINT_VERSION}" + + - name: Run actionlint + run: ${{ steps.get_actionlint.outputs.executable }} -color diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index b945795..ee15859 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -2,11 +2,21 @@ name: Build and Push Docker Image on: push: + branches: + - main # Every merge to main publishes `latest` + `main-` + - dev # Every commit/merge on dev publishes `dev` + `dev-` tags: - 'v*' # Trigger on tags that start with 'v' release: types: [published] +# Serialise builds per ref so an older dev build can never finish last and +# overwrite a moving tag (`dev`/`latest`) with stale code. Superseded branch +# builds are cancelled; tag/release builds always run to completion. +concurrency: + group: docker-publish-${{ github.ref }} + cancel-in-progress: ${{ startsWith(github.ref, 'refs/heads/') }} + env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} @@ -40,9 +50,16 @@ jobs: # Pre-releases (PEP 440 a/b/rc/dev, e.g. v1.4.1rc1) get only their # own tag, never `latest`: prod pulls `latest` via Watchtower, so an # RC must not roll out on its own. contains() is case-insensitive. + # Merges to main also get `latest` (so they deploy via Watchtower) + # plus an immutable `main-` tag for pinning/rollback. + # Pushes to dev get the moving `dev` tag plus `dev-`, and + # never `latest`. tags: | type=ref,event=tag - type=raw,value=latest,enable=${{ !contains(github.ref_name, 'a') && !contains(github.ref_name, 'b') && !contains(github.ref_name, 'rc') && !contains(github.ref_name, 'dev') }} + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || (startsWith(github.ref, 'refs/tags/') && !contains(github.ref_name, 'a') && !contains(github.ref_name, 'b') && !contains(github.ref_name, 'rc') && !contains(github.ref_name, 'dev')) }} + type=sha,prefix=main-,format=short,enable=${{ github.ref == 'refs/heads/main' }} + type=raw,value=dev,enable=${{ github.ref == 'refs/heads/dev' }} + type=sha,prefix=dev-,format=short,enable=${{ github.ref == 'refs/heads/dev' }} - name: Build and push Docker image id: build diff --git a/docs/getting-started.md b/docs/getting-started.md index fd3e355..dde696f 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -46,6 +46,13 @@ docker run --rm \ The application will be available at `http://localhost:5008`. +To try unreleased changes, use `ghcr.io/m-beau/pixelmap:dev` instead. It is +rebuilt on every commit to the `dev` branch, and each build is also pinned as +`dev-` (e.g. `dev-697dbdd`). + +`latest` tracks the `main` branch and is rebuilt on every merge to `main`; +each of those builds is also pinned as `main-`. + :::{note} On Apple Silicon (M1/M2) or ARM Linux, add `--platform linux/amd64` to the Docker command. :::