From 734f23fba3184c166d23e031feaa517755bf8c9e Mon Sep 17 00:00:00 2001 From: Jop Zitman Date: Fri, 9 May 2025 16:29:45 +0800 Subject: [PATCH] Add GH CI for releases --- .github/workflows/release.yaml | 110 +++++++++++++++++++++++++++++++++ Dockerfile | 2 + 2 files changed, 112 insertions(+) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..939710a --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,110 @@ +name: Release slipstream + +on: + push: + tags: + - "v*.*.*" + +env: + BUILD_TYPE: Release + +jobs: + build: + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install build dependencies + run: | + sudo apt-get update + sudo apt install -y pkg-config libssl-dev ninja-build + + - name: Configure CMake + run: | + cmake \ + -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ + -DCMAKE_MAKE_PROGRAM=ninja \ + -DCMAKE_C_COMPILER=clang \ + -DCMAKE_CXX_COMPILER=clang++ \ + -G Ninja \ + -S ${{github.workspace}} \ + -B ${{github.workspace}}/build + + - name: Build with CMake + run: | + cmake \ + --build ${{github.workspace}}/build \ + -j $(nproc) \ + --target slipstream-client slipstream-server + + - name: Rename Binaries + run: | + VERSION=${{ github.ref_name }} + mv ${{github.workspace}}/build/slipstream-client ${{github.workspace}}/build/slipstream-client-${VERSION}-linux-x86_64 + mv ${{github.workspace}}/build/slipstream-server ${{github.workspace}}/build/slipstream-server-${VERSION}-linux-x86_64 + + - name: Release + uses: softprops/action-gh-release@v2 + if: github.ref_type == 'tag' + with: + draft: true + generate_release_notes: true + files: | + build/slipstream-client-* + build/slipstream-server-* + + docker-build: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + attestations: write + id-token: write + + env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push Docker image + id: push + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + - name: Generate artifact attestation + uses: actions/attest-build-provenance@v2 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true diff --git a/Dockerfile b/Dockerfile index 480595f..d770c5f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,4 +41,6 @@ ENV PATH=/usr/src/app/:$PATH COPY --from=builder --chmod=755 /usr/src/app/slipstream-client ./client COPY --from=builder --chmod=755 /usr/src/app/slipstream-server ./server +LABEL org.opencontainers.image.source https://github.com/EndPositive/slipstream + ENTRYPOINT []