diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml new file mode 100644 index 0000000..8e5aa40 --- /dev/null +++ b/.github/workflows/cicd.yml @@ -0,0 +1,78 @@ +name: CI/CD + +on: + push: + branches: ["master", "devel"] + tags: ["v*.*.*"] + pull_request: + branches: ["master"] + +permissions: + contents: write + +jobs: + build: + name: Build + runs-on: ubuntu-latest + env: + GO111MODULE: on + + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: "1.23" + + - name: Install dependencies + run: go get -d + + - name: Build + shell: pwsh + run: ./build.ps1 + + - uses: actions/upload-artifact@v3.1.2 + with: + name: artifact + path: ./bin/* + + release: + name: Release + needs: build + if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/')}} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions/download-artifact@v4 + with: + name: artifact + path: output + + - name: Create a release + uses: softprops/action-gh-release@v1 + with: + files: | + output/**/* + generate_release_notes: true + name: "${{ github.ref_name }}" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to the Container registry + uses: docker/login-action@v2.1.0 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4.0.0 + with: + context: . + platforms: linux/amd64,linux/arm64,linux/arm/v7 + push: true + tags: | + loupeznik/better-wapi:${{ github.ref_name }} + loupeznik/better-wapi:latest