build #46
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: build | |
| on: | |
| push: | |
| # run only against tags | |
| tags: | |
| - "v*" | |
| permissions: | |
| contents: write | |
| packages: write | |
| issues: write | |
| id-token: write | |
| attestations: write | |
| jobs: | |
| goreleaser: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver: docker-container | |
| - name: Login to GHCR | |
| run: echo "${{ secrets.GORELEASER_GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: stable | |
| # More assembly might be required: Docker logins, GPG, etc. | |
| # It all depends on your needs. | |
| - name: Run GoReleaser | |
| uses: goreleaser/goreleaser-action@v6 | |
| with: | |
| # either 'goreleaser' (default) or 'goreleaser-pro' | |
| distribution: goreleaser | |
| # 'latest', 'nightly', or a semver | |
| version: "~> v2" | |
| args: release --clean | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }} | |
| # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution | |
| # GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} | |
| - uses: actions/attest-build-provenance@v3 | |
| with: | |
| subject-checksums: ./dist/checksums.txt | |
| # After GoReleaser runs, attest all the images in ./dist/digests.txt: | |
| - uses: actions/attest-build-provenance@v3 | |
| if: startsWith(github.ref, 'refs/tags/v') # snapshots won't push docker images | |
| with: | |
| subject-checksums: ./dist/digests.txt | |
| - name: Upload dist artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| xbps: | |
| runs-on: ubuntu-latest | |
| needs: goreleaser | |
| container: | |
| image: ghcr.io/void-linux/void-glibc-full:latest | |
| strategy: | |
| matrix: | |
| include: | |
| - arch: x86_64 | |
| goreleaser_arch: amd64 | |
| - arch: i686 | |
| goreleaser_arch: 386 | |
| - arch: aarch64 | |
| goreleaser_arch: arm64 | |
| - arch: armv6l | |
| goreleaser_arch: armv6 | |
| - arch: armv7l | |
| goreleaser_arch: armv7 | |
| steps: | |
| - name: Download dist artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| - name: Extract version | |
| id: version | |
| run: | | |
| VERSION=$(cat dist/metadata.json | grep -o '"version":"[^"]*"' | cut -d'"' -f4) | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| - name: Build XBPS package | |
| run: | | |
| xbps-install -Sy xbps | |
| BINARY="dist/d4s_linux_${{ matrix.goreleaser_arch }}*/d4s" | |
| if [ "${{ matrix.goreleaser_arch }}" = "armv6" ]; then | |
| BINARY="dist/d4s_linux_arm_6/d4s" | |
| elif [ "${{ matrix.goreleaser_arch }}" = "armv7" ]; then | |
| BINARY="dist/d4s_linux_arm_7/d4s" | |
| fi | |
| # Create package structure | |
| PKG_DIR="pkg_${{ matrix.arch }}" | |
| mkdir -p "${PKG_DIR}/usr/bin" | |
| mkdir -p "${PKG_DIR}/usr/share/doc/d4s" | |
| cp ${BINARY} "${PKG_DIR}/usr/bin/d4s" | |
| chmod 755 "${PKG_DIR}/usr/bin/d4s" | |
| cp dist/d4s_linux_${{ matrix.goreleaser_arch }}*/LICENSE* "${PKG_DIR}/usr/share/doc/d4s/" 2>/dev/null || cp LICENSE "${PKG_DIR}/usr/share/doc/d4s/" 2>/dev/null || true | |
| cp dist/d4s_linux_${{ matrix.goreleaser_arch }}*/README* "${PKG_DIR}/usr/share/doc/d4s/" 2>/dev/null || cp README.md "${PKG_DIR}/usr/share/doc/d4s/" 2>/dev/null || true | |
| # Create XBPS package | |
| cd "${PKG_DIR}" | |
| xbps-create -A ${{ matrix.arch }} \ | |
| -n "d4s-${{ steps.version.outputs.version }}_1" \ | |
| -s "Master Docker like a pro, right from your terminal" \ | |
| -l "Apache-2.0" \ | |
| -m "jr-k <jrk@jierka.com>" \ | |
| -H "https://d4scli.io" \ | |
| . | |
| mv *.xbps ../ | |
| - name: Upload XBPS to release | |
| env: | |
| GH_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }} | |
| run: | | |
| xbps-install -Sy github-cli | |
| gh release upload "${{ github.ref_name }}" *.xbps --repo "${{ github.repository }}" | |
| gentoo: | |
| runs-on: ubuntu-latest | |
| needs: goreleaser | |
| steps: | |
| - name: Download dist artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| - name: Extract version | |
| id: version | |
| run: | | |
| VERSION=$(cat dist/metadata.json | grep -o '"version":"[^"]*"' | cut -d'"' -f4) | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| - name: Checkout overlay repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: jr-k/gentoo-d4s | |
| token: ${{ secrets.GORELEASER_GITHUB_TOKEN }} | |
| path: overlay | |
| - name: Generate ebuild and Manifest | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| EBUILD_DIR="overlay/app-misc/d4s" | |
| mkdir -p "${EBUILD_DIR}" | |
| # Create ebuild | |
| cat > "${EBUILD_DIR}/d4s-${VERSION}.ebuild" << 'EBUILD_EOF' | |
| # Copyright 2024 Gentoo Authors | |
| # Distributed under the terms of the Apache-2.0 license | |
| EAPI=8 | |
| DESCRIPTION="Master Docker like a pro, right from your terminal" | |
| HOMEPAGE="https://d4scli.io https://github.com/jr-k/d4s" | |
| BASE_URI="https://github.com/jr-k/d4s/releases/download/v${PV}" | |
| SRC_URI=" | |
| amd64? ( ${BASE_URI}/d4s_${PV}_linux_amd64.tar.gz ) | |
| arm64? ( ${BASE_URI}/d4s_${PV}_linux_arm64.tar.gz ) | |
| arm? ( ${BASE_URI}/d4s_${PV}_linux_armv7.tar.gz ) | |
| x86? ( ${BASE_URI}/d4s_${PV}_linux_x86.tar.gz ) | |
| " | |
| LICENSE="Apache-2.0" | |
| SLOT="0" | |
| KEYWORDS="~amd64 ~arm ~arm64 ~x86" | |
| RDEPEND="" | |
| DEPEND="" | |
| S="${WORKDIR}" | |
| QA_PREBUILT="usr/bin/d4s" | |
| src_install() { | |
| dobin d4s | |
| dodoc README.md LICENSE | |
| } | |
| EBUILD_EOF | |
| # Remove leading spaces from heredoc | |
| sed -i 's/^ //' "${EBUILD_DIR}/d4s-${VERSION}.ebuild" | |
| # Create metadata if not exists | |
| mkdir -p overlay/metadata | |
| cat > overlay/metadata/layout.conf << 'EOF' | |
| masters = gentoo | |
| auto-sync = false | |
| EOF | |
| sed -i 's/^ //' overlay/metadata/layout.conf | |
| # Create profiles if not exists | |
| mkdir -p overlay/profiles | |
| echo "gentoo-d4s" > overlay/profiles/repo_name | |
| # Generate Manifest with checksums | |
| cd "${EBUILD_DIR}" | |
| for arch in amd64 arm64 armv7 x86; do | |
| TARBALL="d4s_${VERSION}_linux_${arch}.tar.gz" | |
| URL="https://github.com/jr-k/d4s/releases/download/v${VERSION}/${TARBALL}" | |
| curl -sL -o "/tmp/${TARBALL}" "${URL}" | |
| SIZE=$(stat -c%s "/tmp/${TARBALL}") | |
| SHA512=$(sha512sum "/tmp/${TARBALL}" | cut -d' ' -f1) | |
| BLAKE2B=$(b2sum "/tmp/${TARBALL}" | cut -d' ' -f1) | |
| echo "DIST ${TARBALL} ${SIZE} BLAKE2B ${BLAKE2B} SHA512 ${SHA512}" >> Manifest | |
| done | |
| - name: Commit and push overlay | |
| working-directory: overlay | |
| run: | | |
| git config user.name "GoReleaser Bot" | |
| git config user.email "bot@goreleaser.com" | |
| git add -A | |
| git commit -m "Update d4s to ${{ steps.version.outputs.version }}" || exit 0 | |
| git push |