diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..2cb101287 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,142 @@ +name: Build + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + workflow_call: + + +jobs: + linux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.20' + + - name: Build + run: make static-linux + + - name: Upload + if: ${{ github.event_name == 'release' }} + uses: actions/upload-artifact@v3 + with: + name: cri-dockerd + retention-days: 5 + path: | + packaging/static/**/**/**/*.tgz + + deb: + if: ${{ github.event_name == 'release' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.20' + + - name: Build + run: make deb + + - name: Upload + uses: actions/upload-artifact@v3 + with: + name: cri-dockerd + retention-days: 5 + path: | + packaging/deb/**/**/**/*.deb + + rpm: + if: ${{ github.event_name == 'release' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.20' + + - name: Build + run: make rpm + + - name: Upload + uses: actions/upload-artifact@v3 + with: + name: cri-dockerd + retention-days: 5 + path: | + packaging/rpm/**/**/**/*.rpm + + arm: + if: ${{ github.event_name == 'release' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.20' + + - name: Build + run: make cross-arm + + - name: Upload + uses: actions/upload-artifact@v3 + with: + name: cri-dockerd + retention-days: 5 + path: | + packaging/static/**/**/**/*.tgz + + windows: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.20' + + - name: Build + run: make cross-win + + - name: Upload + if: ${{ github.event_name == 'release' }} + uses: actions/upload-artifact@v3 + with: + name: cri-dockerd + retention-days: 5 + path: | + packaging/static/**/**/**/*.zip + + mac: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.20' + + - name: Build + run: make cross-mac + + - name: Upload + if: ${{ github.event_name == 'release' }} + uses: actions/upload-artifact@v3 + with: + name: cri-dockerd + retention-days: 5 + path: | + packaging/static/**/**/**/*.tgz diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 72cf22b9d..000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: CI - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -jobs: - - build-linux: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: '1.20' - - - name: Build - run: make static-linux - - build-windows: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: '1.20' - - - name: Build - run: make cross-win - - build-mac: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: '1.20' - - - name: Build - run: make cross-mac - - build-arm: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: '1.20' - - - name: Build - run: make cross-arm diff --git a/.github/workflows/hugo.yml b/.github/workflows/docs.yml similarity index 94% rename from .github/workflows/hugo.yml rename to .github/workflows/docs.yml index d7369c3be..9248ec232 100644 --- a/.github/workflows/hugo.yml +++ b/.github/workflows/docs.yml @@ -2,9 +2,7 @@ name: Deploy Hugo site to Pages on: - # Runs on pushes targeting the default branch - push: - branches: ["master"] + workflow_call: # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -27,7 +25,6 @@ defaults: shell: bash jobs: - # Build job build: runs-on: ubuntu-latest env: @@ -63,8 +60,7 @@ jobs: with: path: ./docs/public - # Deployment job - deploy: + publish: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 4de9e4ed6..665c6a5c6 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -5,6 +5,7 @@ on: branches: [ master ] pull_request: branches: [ master ] + workflow_call: jobs: e2e-test: diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 45c386afc..b158b4eef 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -5,6 +5,7 @@ on: branches: [ master ] pull_request: branches: [ master ] + workflow_call: jobs: integration: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8ba368349..ab9c914dd 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,30 +1,21 @@ -name: Build and publish artifacts +name: Publish on: - release: - types: [created] + workflow_call: jobs: - releases-matrix: - name: Build and publish static binaries + publish-binaries: runs-on: ubuntu-latest - strategy: - matrix: - goos: [linux, darwin, windows] - goarch: [amd64, arm64] - exclude: - - goarch: "arm64" - goos: windows - steps: - - uses: actions/checkout@v2 - - uses: wangyoucao577/go-release-action@v1.38 + - uses: actions/download-artifact@v3 + with: + name: cri-dockerd + - name: Push binaries + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') with: - github_token: ${{ secrets.GITHUB_TOKEN }} - goos: ${{ matrix.goos }} - goarch: ${{ matrix.goarch }} - project_path: "./" - binary_name: "cri-dockerd" - pre_command: "export CGO_ENABLED=0" - extra_files: LICENSE README.md - overwrite: true + files: | + **/*.tgz + **/*.rpm + **/*.deb + **/*.zip diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..bce0c5855 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,21 @@ +name: Release + +on: + release: + types: [prereleased] + +jobs: + build: + uses: ./.github/workflows/build.yml + e2e: + uses: ./.github/workflows/e2e.yml + integration: + uses: ./.github/workflows/integration.yml + publish: + if: ${{ always() && contains(join(needs.*.result, ','), 'success') }} + needs: [build, e2e, integration] + uses: ./.github/workflows/publish.yml + docs: + if: ${{ always() && contains(join(needs.*.result, ','), 'success') }} + needs: [build, e2e, integration] + uses: ./.github/workflows/docs.yml diff --git a/Makefile b/Makefile index 48895b5d9..79bd1558f 100644 --- a/Makefile +++ b/Makefile @@ -63,37 +63,6 @@ clean: ## clean the build artifacts $(RM) -r build -$(MAKE) -C $(PACKAGING_DIR) clean -.PHONY: release -release: static deb rpm cross-arm cross-mac cross-win ## build the release binaries - mkdir -p $(RELEASE_DIR) - - # Copy the release files - # Debian - cp $(PACKAGING_DIR)/deb/debbuild/debian-bullseye/cri-dockerd_$(VERSION)~3-0~debian-bullseye_amd64.deb $(RELEASE_DIR) - cp $(PACKAGING_DIR)/deb/debbuild/debian-buster/cri-dockerd_$(VERSION)~3-0~debian-buster_amd64.deb $(RELEASE_DIR) - # Ubuntu - cp $(PACKAGING_DIR)/deb/debbuild/ubuntu-bionic/cri-dockerd_$(VERSION)~3-0~ubuntu-bionic_amd64.deb $(RELEASE_DIR) - cp $(PACKAGING_DIR)/deb/debbuild/ubuntu-focal/cri-dockerd_$(VERSION)~3-0~ubuntu-focal_amd64.deb $(RELEASE_DIR) - cp $(PACKAGING_DIR)/deb/debbuild/ubuntu-jammy/cri-dockerd_$(VERSION)~3-0~ubuntu-jammy_amd64.deb $(RELEASE_DIR) - # CentOS - cp $(PACKAGING_DIR)/rpm/rpmbuild/RPMS/x86_64/cri-dockerd-$(VERSION).*.el7.x86_64.rpm $(RELEASE_DIR) - cp $(PACKAGING_DIR)/rpm/rpmbuild/RPMS/x86_64/cri-dockerd-$(VERSION).*.el8.x86_64.rpm $(RELEASE_DIR) - cp $(PACKAGING_DIR)/rpm/rpmbuild/SRPMS/cri-dockerd-$(VERSION).*.el7.src.rpm $(RELEASE_DIR) - cp $(PACKAGING_DIR)/rpm/rpmbuild/SRPMS/cri-dockerd-$(VERSION).*.el8.src.rpm $(RELEASE_DIR) - # Fedora - cp $(PACKAGING_DIR)/rpm/rpmbuild/RPMS/x86_64/cri-dockerd-$(VERSION).*.fc35.x86_64.rpm $(RELEASE_DIR) - cp $(PACKAGING_DIR)/rpm/rpmbuild/RPMS/x86_64/cri-dockerd-$(VERSION).*.fc36.x86_64.rpm $(RELEASE_DIR) - cp $(PACKAGING_DIR)/rpm/rpmbuild/SRPMS/cri-dockerd-$(VERSION).*.fc35.src.rpm $(RELEASE_DIR) - cp $(PACKAGING_DIR)/rpm/rpmbuild/SRPMS/cri-dockerd-$(VERSION).*.fc36.src.rpm $(RELEASE_DIR) - # arm - cp $(PACKAGING_DIR)/static/build/arm/cri-dockerd-$(VERSION).tgz $(RELEASE_DIR)/cri-dockerd-$(VERSION).arm64.tgz - # win - cp $(PACKAGING_DIR)/static/build/win/cri-dockerd-$(VERSION).zip $(RELEASE_DIR)/cri-dockerd-$(VERSION).win.amd64.zip - # mac - cp $(PACKAGING_DIR)/static/build/mac/cri-dockerd-$(VERSION).tgz $(RELEASE_DIR)/cri-dockerd-$(VERSION).darwin.amd64.tgz - # linux - cp $(PACKAGING_DIR)/static/build/linux/cri-dockerd-$(VERSION).tgz $(RELEASE_DIR)/cri-dockerd-$(VERSION).amd64.tgz - .PHONY: run run: cri-dockerd ## Run cri-docker in a running minikube sudo ./cri-dockerd --log-level debug --network-plugin="" diff --git a/packaging/static/Makefile b/packaging/static/Makefile index bb6b1fa51..b16e2337d 100644 --- a/packaging/static/Makefile +++ b/packaging/static/Makefile @@ -51,7 +51,7 @@ static-linux: mkdir -p build/linux/cri-dockerd cd $(APP_DIR) && env CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=$(ARCH) go build -trimpath ${CRI_DOCKERD_LDFLAGS} -o cri-dockerd mv $(APP_DIR)/cri-dockerd build/linux/cri-dockerd/cri-dockerd - tar -C build/linux -c -z -f build/linux/cri-dockerd-$(VERSION).tgz cri-dockerd + tar -C build/linux -c -z -f build/linux/cri-dockerd-$(VERSION).amd64.tgz cri-dockerd .PHONY: hash_files hash_files: @@ -63,7 +63,7 @@ cross-mac: mkdir -p build/mac/cri-dockerd cd $(APP_DIR) && env CGO_ENABLED=$(CGO_ENABLED) GOOS=darwin GOARCH=$(ARCH) go build -trimpath ${CRI_DOCKERD_LDFLAGS} -o cri-dockerd-darwin-amd64 mv $(APP_DIR)/cri-dockerd-darwin-amd64 build/mac/cri-dockerd/cri-dockerd - tar -C build/mac -c -z -f build/mac/cri-dockerd-$(VERSION).tgz cri-dockerd + tar -C build/mac -c -z -f build/mac/cri-dockerd-$(VERSION).darwin.amd64.tgz cri-dockerd .PHONY: cross-win cross-win: @@ -71,7 +71,7 @@ cross-win: cd $(APP_DIR) && env CGO_ENABLED=$(CGO_ENABLED) GOOS=windows GOARCH=$(ARCH) go build -trimpath ${CRI_DOCKERD_LDFLAGS} -o cri-dockerd-windows-amd64 mv $(APP_DIR)/cri-dockerd-windows-amd64 build/win/cri-dockerd/cri-dockerd.exe if ! grep -sq 'docker\|lxc' /proc/1/cgroup; then \ - docker run --rm -v $(CURDIR)/build/win:/v -w /v alpine sh -c 'apk update && apk add zip && zip -r cri-dockerd-$(VERSION).zip cri-dockerd'; \ + docker run --rm -v $(CURDIR)/build/win:/v -w /v alpine sh -c 'apk update && apk add zip && zip -r cri-dockerd-$(VERSION).win.amd64.zip cri-dockerd'; \ $(CHOWN) -R $(shell id -u):$(shell id -g) build; \ fi @@ -80,4 +80,4 @@ cross-arm: ## create tgz with linux arm64 client only mkdir -p build/arm/cri-dockerd cd $(APP_DIR) && env CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=arm64 go build -trimpath ${CRI_DOCKERD_LDFLAGS} -o cri-dockerd-arm64 mv $(APP_DIR)/cri-dockerd-arm64 build/arm/cri-dockerd/cri-dockerd - tar -C build/arm -c -z -f build/arm/cri-dockerd-$(VERSION).tgz cri-dockerd + tar -C build/arm -c -z -f build/arm/cri-dockerd-$(VERSION).arm64.tgz cri-dockerd