diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..1eabd49 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,52 @@ +name: CI +on: + push: + branches: + - main + +env: + DOCKER_USERNAME: thedoorknobster + REPO: thedoorknobster/sample-app + +jobs: + docker: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + # Fetch all commits + fetch-depth: 0 + + - name: Semantic versioning + id: versioning + uses: PaulHatch/semantic-version@v4.0.2 + with: + branch: main + tag_prefix: "v" + major_pattern: "BREAKING CHANGE:" + minor_pattern: "feat:" + format: "v${major}.${minor}.${patch}-prerelease${increment}" + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ env.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push + uses: docker/build-push-action@v2 + with: + push: true + tags: ${{ env.REPO }}:latest,${{ env.REPO }}:${{ steps.versioning.outputs.version }} + + - name: Create Release + if: ${{ !startsWith(github.ref, 'refs/tags/') }} + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.github_token }} + with: + tag_name: ${{ steps.versioning.outputs.version }} + release_name: ${{ steps.versioning.outputs.version }} + prerelease: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..841ccdf --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,38 @@ +name: release +on: + push: + tags: + - 'v*' + +env: + DOCKER_USERNAME: thedoorknobster + REPO: thedoorknobster/sample-app + +jobs: + docker: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + # Fetch all commits + fetch-depth: 0 + + - name: Set environment variables + run: | + cat >> $GITHUB_ENV << EOF + VERSION=${GITHUB_REF##*/} + EOF + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ env.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push + uses: docker/build-push-action@v2 + with: + push: true + tags: ${{ env.REPO }}:latest,${{ env.REPO }}:${{ env.VERSION }}