Skip to content

Commit

Permalink
build a docker image on merge to main
Browse files Browse the repository at this point in the history
Push to `yshavit/mdq:latest` on merge to main, with an option to also
push to a stable release version (e.g. `0.3.1`).

In service of #217.
  • Loading branch information
yshavit authored Feb 28, 2025
1 parent f121418 commit 1377a06
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ name: build-release
on:
push:
branches: [ "main" ]
workflow_dispatch:
inputs:
docker-tag-type:
description: The docker tag to upload as
required: true
default: latest
type: choice
options:
- latest
- stable

env:
CARGO_TERM_COLOR: always
Expand All @@ -14,6 +24,41 @@ permissions:
contents: read

jobs:
docker:
environment: Docker Hub
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: get tag
id: get-tag
run: |
if [[ "${DOCKER_TAG_TYPE}" = 'stable' ]]; then
tag="$(cargo metadata --format-version 1 | jq -r '.packages[] | select(.name == "mdq") | .version')"
else
tag=latest
fi
echo "tag=$tag" >> "$GITHUB_OUTPUT"
env:
DOCKER_TAG_TYPE: ${{ inputs.docker-tag-type }}
DOCKER_USERNAME: ${{ vars.DOCKERHUB_USERNAME }}
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PAT }}
- name: Gather metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ vars.DOCKERHUB_USERNAME }}/mdq
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ vars.DOCKERHUB_USERNAME}}/mdq:${{ steps.get-tag.outputs.tag }}
labels: ${{ steps.meta.outputs.labels }}

build:
strategy:
matrix:
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ Any of these will work:
2. ```shell
brew install mdq
```
3. Download binaries from [the latest release] (or any other release, of course).
4. You can also grab the binaries from the latest [build-release] workflow run. You must be logged into GitHub to do
3. ```bash
docker pull yshavit/mdq
echo 'My [example](https://github.com/yshavit/mdq) markdown' | docker run --rm -i yshavit/mdq '[]()'
```
4. Download binaries from [the latest release] (or any other release, of course).

You can also grab the binaries from the latest [build-release] workflow run. You must be logged into GitHub to do
that (this is GitHub's limitation, not mine). You'll have to `chmod +x` them before you can run them.

<details>
Expand Down

0 comments on commit 1377a06

Please sign in to comment.