Repository: bbfrederick/rapidtide (language: python)

Issue:
Publish Docker image automatically on release with GitHub Actions
**Is your feature request related to a problem? Please describe.**
It isn't related to a problem, but I think it would streamline the release process if you used a GitHub Action to publish the Docker image to Docker Hub automatically.

**Describe the solution you'd like**
GitHub has some documentation on doing this: [Publishing Docker images](https://docs.github.com/en/actions/guides/publishing-docker-images). I could open a PR that would probably get it most of the way there, though there might be some repository settings (e.g., secret variables for your DockerHub username and password) that would need to be changed.

**Describe alternatives you've considered**
Manually uploading is still completely reasonable, but it takes longer and breaks the release process into multiple steps instead of just one.

**Additional context**
None.


Discussion / hints:
I've implemented the suggestion, and it works partially.  On any commit, the container is rebuilt, and pushed to DockerHub as "latest".  However, I can't for the life of me figure out how to push it with it's proper git tag, despite many articles purporting to offer solutions.  If you can figure that out, that would be great.

Also, once we get this working, I think it would be best to only make and push new containers when the tag changes - the code for that is in place but commented out.

Fix patch:
diff --git a/.github/workflows/docker-build-on-release.yml b/.github/workflows/docker-build-on-release.yml
new file mode 100644
index 000000000..ee55d0f2e
--- /dev/null
+++ b/.github/workflows/docker-build-on-release.yml
@@ -0,0 +1,37 @@
+name: Upload release to DockerHub
+
+on:
+  release:
+    types: [published]
+
+jobs:
+  docker:
+
+    runs-on: ubuntu-latest
+
+    steps:
+      - name: Set up QEMU
+        uses: docker/setup-qemu-action@v1
+
+      - name: Set up Docker Buildx
+        uses: docker/setup-buildx-action@v1
+
+      - name: Login to DockerHub
+        uses: docker/login-action@v1
+        with:
+          username: ${{ secrets.DOCKERHUB_USERNAME }}
+          password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+      - name: Extract metadata (tags, labels) for Docker
+        id: meta
+        uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
+        with:
+          images: fredericklab/rapidtide
+
+      - name: Build and push
+        id: docker_build
+        uses: docker/build-push-action@v2
+        with:
+          push: true
+          tags: ${{ steps.meta.outputs.tags }}
+          labels: ${{ steps.meta.outputs.labels }}
diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml
index 27a65a893..88d6b3450 100644
--- a/.github/workflows/python-publish.yml
+++ b/.github/workflows/python-publish.yml
@@ -5,7 +5,7 @@ name: Upload Python Package
 
 on:
   release:
-    types: [created]
+    types: [published]
 
 jobs:
   deploy:
diff --git a/newrelease_todo b/newrelease_todo
index 2cf49bfce..a47df6b8b 100644
--- a/newrelease_todo
+++ b/newrelease_todo
@@ -1,29 +1,11 @@
-+ Fix the version numbers in files:
-
-    vi newrelease_todo
-
-    newrelease_todo
-        fix tag numbers in this file
-
 + Edit CHANGELOG.md (use git log to get the history)
 
-+ Sync everything to github.
-
-+ Build rapidtide
-
-    python setup.py install
-
-+ Create a new tag (instructions from https://git-scm.com/book/en/v2/Git-Basics-Tagging) and push to github:
-
-    git tag -a v2.0.9 -m "v2.0.9"
-    git push origin v2.0.9
-
-+ Build rapidtide
-
-    python setup.py install
-
-+ Edit the release notes on github
++ Sync everything to GitHub
 
-+ Build and sync new docker images
++ Create a new release
+    git tag -a vX.Y.Z -m "vX.Y.Z"
+    git push origin vX.Y.Z
+    
++ Edit new tag on GitHub
 
-    builddocker.sh
++ Check the DockerHub and PyPi deployment Actions


Test patch:
diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build-latest.yml
similarity index 58%
rename from .github/workflows/docker-build.yml
rename to .github/workflows/docker-build-latest.yml
index 8832d998e..49b997157 100644
--- a/.github/workflows/docker-build.yml
+++ b/.github/workflows/docker-build-latest.yml
@@ -1,41 +1,35 @@
-name: ci
+name: Upload latest to DockerHub
 
 on:
   push:
     branches:
       - 'main'
-    #tags:
-    #  - "v*.*.*"
 
 jobs:
   docker:
+
     runs-on: ubuntu-latest
+
     steps:
-      -
-        name: Set up QEMU
+      - name: Set up QEMU
         uses: docker/setup-qemu-action@v1
 
-      -
-        name: Set up Docker Buildx
+      - name: Set up Docker Buildx
         uses: docker/setup-buildx-action@v1
 
-      -
-        name: Login to DockerHub
-        uses: docker/login-action@v1 
+      - name: Login to DockerHub
+        uses: docker/login-action@v1
         with:
           username: ${{ secrets.DOCKERHUB_USERNAME }}
           password: ${{ secrets.DOCKERHUB_TOKEN }}
 
-      -
-        name: Get version number
+      - name: Get version number
         id: get_version
         run: echo ::set-output name=VERSION::${{ github.ref }}
 
-      -
-        name: Build and push
+      - name: Build and push
         id: docker_build
         uses: docker/build-push-action@v2
         with:
           push: true
           tags: fredericklab/rapidtide:latest
-          #tags: fredericklab/rapidtide:${{ steps.get_version.outputs.VERSION }}, fredericklab/rapidtide:latest