diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..dc1feb0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,35 @@ +name: Docker Hub + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + - '!v[0-9]+.[0-9]+.[0-9]+[ab][0-9]+' + +jobs: + + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Get version + id: vars + run: echo "version=${GITHUB_REF:11}" >> $GITHUB_OUTPUT + + - name: Set up Docker buildx + uses: docker/setup-buildx-action@v3 + with: + platforms: linux/amd64,linux/arm64 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ github.repository }}:latest,${{ github.repository }}:${{ steps.vars.outputs.version }} diff --git a/README.md b/README.md index cb00e6c..8684c6d 100644 --- a/README.md +++ b/README.md @@ -38,12 +38,9 @@ cat bmiheatc.out A versioned, multiplatform image built from this repository is hosted on Docker Hub at [csdms/bmi-example-c](https://hub.docker.com/repository/docker/csdms/bmi-example-c-docker/). -To tag, build, and push an update, run: -``` -docker buildx build --platform linux/amd64,linux/arm64 -t csdms/bmi-example-c: --push . -``` -where `` is, e.g., `0.1` or `latest`. - +This image is automatically built and pushed to Docker Hub +with the [release](./.github/workflows/release.yml) CI workflow. +The workflow is only run when the repository is tagged. A user can pull this image from Docker Hub with: ``` docker pull csdms/bmi-example-c