diff --git a/.github/workflows/build_prod.yml b/.github/workflows/build_prod.yml new file mode 100644 index 0000000..599500f --- /dev/null +++ b/.github/workflows/build_prod.yml @@ -0,0 +1,37 @@ +name: Build image on MAIN branch + +on: + push: + tags: + - 'v*' + pull_request: + tags: + - 'v*' + +jobs: + package-image: + runs-on: ubuntu-latest + if: contains(github.event.head_commit.message, '[release]') + environment: + name: production # Set the environment name + steps: + - uses: actions/checkout@v4 + - name: Login to VngCloud Registry + uses: docker/login-action@v3 + with: + registry: ${{ vars.VCR_REGISTRY }} + username: ${{ secrets.VCR_USERNAME }} + password: ${{ secrets.VCR_PASSWORD }} + - name: Get previous tag + id: previoustag + uses: "WyriHaximus/github-action-get-previous-tag@v1" + with: + fallback: 1.0.0 # Optional fallback tag to use when no tag can be found + #workingDirectory: another/path/where/a/git/repo/is/checked/out # Optional alternative working directory + - name: Build and push vngcloud-blockstorage-csi-driver image + env: + NEW_VERSION: ${{ steps.previoustag.outputs.tag }} + run: | + export REGISTRY=${{ vars.VCR_REGISTRY }} + export VERSION=${NEW_VERSION} + make bush-local-images \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3ec4f0b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,33 @@ +name: Release vngcloud-blockstorage-csi-driver project + +on: + push: + tags: + - 'v*' + pull_request: + tags: + - 'v*' + +jobs: + build: + name: GoReleaser build + runs-on: ubuntu-latest + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v4 + with: + fetch-depth: 0 # See: https://goreleaser.com/ci/actions/ + + - name: Set up Go 1.22 + uses: actions/setup-go@v4 + with: + go-version: 1.22 + id: go + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GO_RELEASER_GITHUB_TOKEN }} \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..c22bf9e --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,3 @@ +# .goreleaser.yaml +builds: + - main: cmd/vngcloud-blockstorage-csi-driver/main.go \ No newline at end of file diff --git a/Makefile b/Makefile index 869e807..e8b5c7a 100644 --- a/Makefile +++ b/Makefile @@ -145,9 +145,19 @@ build-local-image-%: --tag $(REGISTRY)/$*:$(VERSION) \ . +bush-image-%: + $(CONTAINER_ENGINE) build \ + --build-arg VERSION=$(VERSION) \ + --tag $(REGISTRY)/$*:$(VERSION) \ + . + + $(CONTAINER_ENGINE) image push $(REGISTRY)/$*:$(VERSION) + # Build all images locally build-local-images: $(addprefix build-local-image-,$(IMAGE_NAMES)) +bush-local-images: $(addprefix bush-image-,$(IMAGE_NAMES)) + # Build a single image for all architectures in ARCHS and push it to REGISTRY push-multiarch-image-%: $(CONTAINER_ENGINE) buildx build --output type=registry \