From a234fe00eada824e93f382be1923d8e6edbfcc64 Mon Sep 17 00:00:00 2001 From: Ethan Turner Date: Sat, 4 Mar 2023 13:42:45 -0800 Subject: [PATCH] ci: add semver release and Docker build workflow --- .github/workflows/release-and-build.yaml | 40 ++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/release-and-build.yaml diff --git a/.github/workflows/release-and-build.yaml b/.github/workflows/release-and-build.yaml new file mode 100644 index 0000000..d40986d --- /dev/null +++ b/.github/workflows/release-and-build.yaml @@ -0,0 +1,40 @@ +name: Release SemVer and Build Docker Image + +on: + push: + branches: + - main + +jobs: + release: + name: Release new semantic version + runs-on: ubuntu-latest + outputs: + didRelease: ${{ steps.semver.outputs.new_release_published }} + newVersion: ${{ steps.semver.outputs.new_release_version }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: semantic-release + uses: cycjimmy/semantic-release-action@v3 + id: semver + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + build: + name: Build Docker image + needs: release + if: needs.release.outputs.didRelease == 'true' + runs-on: ubuntu-latest + steps: + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: format('{0}:{1}', github.repository, needs.release.outputs.newVersion) \ No newline at end of file