|
| 1 | +name: development-release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - development |
| 7 | + |
| 8 | +jobs: |
| 9 | + compile: |
| 10 | + name: Cross compile binaries |
| 11 | + runs-on: ubuntu-latest |
| 12 | + container: |
| 13 | + image: golangci/golangci-lint:latest |
| 14 | + steps: |
| 15 | + - name: Checkout Code |
| 16 | + uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + fetch-depth: 0 |
| 19 | + - name: Make repo safe |
| 20 | + run: git config --global --add safe.directory /__w/SOARCA/SOARCA |
| 21 | + |
| 22 | + - name: Install swaggo |
| 23 | + run: go install github.com/swaggo/swag/cmd/swag@latest |
| 24 | + |
| 25 | + - name: Build with make |
| 26 | + run: | |
| 27 | + go install github.com/swaggo/swag/cmd/swag@latest |
| 28 | + go install github.com/CycloneDX/cyclonedx-gomod/cmd/cyclonedx-gomod@latest |
| 29 | + make compile |
| 30 | + make sbom |
| 31 | +
|
| 32 | + - name: 'Upload Artifact' |
| 33 | + uses: actions/upload-artifact@v4 |
| 34 | + with: |
| 35 | + name: ${{ github.sha }} |
| 36 | + path: bin/* |
| 37 | + retention-days: 1 |
| 38 | + |
| 39 | + docker-build: |
| 40 | + needs: compile |
| 41 | + name: Build docker image and push it to docker hub |
| 42 | + runs-on: ubuntu-latest |
| 43 | + steps: |
| 44 | + - name: Checkout Code |
| 45 | + uses: actions/checkout@v4 |
| 46 | + with: |
| 47 | + fetch-depth: 0 |
| 48 | + - name: Make repo safe |
| 49 | + run: git config --global --add safe.directory /__w/SOARCA/SOARCA |
| 50 | + |
| 51 | + - name: Set up QEMU |
| 52 | + uses: docker/setup-qemu-action@v3 |
| 53 | + - name: Set up Docker Buildx |
| 54 | + uses: docker/setup-buildx-action@v3 |
| 55 | + |
| 56 | + - name: Download bin |
| 57 | + uses: actions/download-artifact@v4 |
| 58 | + with: |
| 59 | + pattern: ${{ github.sha }} |
| 60 | + |
| 61 | + - name: Move files to bin folder and make executable |
| 62 | + run: | |
| 63 | + mkdir -p bin |
| 64 | + mv ${{ github.sha }}/* ./bin/ |
| 65 | + chmod +x bin/soarca-* |
| 66 | +
|
| 67 | + - name: Login to Docker Hub |
| 68 | + uses: docker/login-action@v3 |
| 69 | + with: |
| 70 | + username: ${{ secrets.DOCKER_HUB_USER }} |
| 71 | + password: ${{ secrets.DOCKER_HUB_TOKEN }} |
| 72 | + |
| 73 | + - name: Get version |
| 74 | + run: | |
| 75 | + export VERSION=$(git describe --tags --dirty) |
| 76 | + echo "describe_version=$(git describe --tags --dirty)" >> "$GITHUB_ENV" |
| 77 | +
|
| 78 | + - name: Build and push |
| 79 | + uses: docker/build-push-action@v5 |
| 80 | + with: |
| 81 | + context: . |
| 82 | + build-args: | |
| 83 | + VERSION=${{ env.describe_version }} |
| 84 | + platforms: | |
| 85 | + - linux/amd64 |
| 86 | + - linux/arm64 |
| 87 | + push: true |
| 88 | + tags: cossas/soarca:development |
0 commit comments