diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 623a7a1..898e4ff 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -29,17 +29,65 @@ jobs: files: coverage.out token: ${{ secrets.CODECOV_TOKEN }} slug: snapp-incubator/nats-blackbox-exporter - gorelease: - name: release - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v4 - with: - go-version: "1.22" - - uses: goreleaser/goreleaser-action@v4 - with: - version: latest - args: release --rm-dist - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + build-push: + name: Build & Push + runs-on: ubuntu-latest + needs: + - lint + # - test + strategy: + matrix: + command: [janus, ion-sfu] + env: + REGISTRY: ghcr.io + USERNAME: ${{ github.repository_owner }} + REPOSITORY: ${{ github.event.repository.name }} + steps: + - name: Install Go + uses: actions/setup-go@v4 + with: + go-version: 1.22.x + + - name: Checks out our project source code + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ env.USERNAME }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: docker/metadata-action@v3 + id: meta + with: + images: ${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.REPOSITORY }}-${{ matrix.command }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - name: Generate Dockerfile + run: | + render() { + sedStr="s!%%COMMAND%%!$command!g;" + sed -r "$sedStr" $1 + } + + command=${{ matrix.command }} + render build/template.Dockerfile > build/$command.Dockerfile + + - uses: docker/build-push-action@v2 + with: + file: "build/${{ matrix.command }}.Dockerfile" + context: . + platforms: linux/amd64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..c3f06bc --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,21 @@ +--- +name: release +on: + push: + tags: + - '*' +jobs: + gorelease: + name: release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v4 + with: + go-version: "1.22" + - uses: goreleaser/goreleaser-action@v4 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file