diff --git a/.github/workflows/deliver-ubuntu.yml b/.github/workflows/delivery-ubuntu.yml similarity index 54% rename from .github/workflows/deliver-ubuntu.yml rename to .github/workflows/delivery-ubuntu.yml index f36cbcce1..5864997e5 100644 --- a/.github/workflows/deliver-ubuntu.yml +++ b/.github/workflows/delivery-ubuntu.yml @@ -9,35 +9,33 @@ on: tag_name: description: The release tag to distribute required: true - ubuntu_ppa: - description: flag indicating this is an ubuntu release - required: true - jobs: create-ppa: - #if: github.event_name == 'release' strategy: fail-fast: false matrix: - target: [xenial, bionic, focal] include: - - target: xenial - runner: ubuntu-16.04 - image: docker://ubuntu:16.04 - i386-go-version: 1.13 - target: bionic - runner: ubuntu-18.04 - image: docker://ubuntu:18.04 - i386-go-version: 1.15 + go-dep-entry: golang (>=1.16) + go-dep-package-name: golang - target: focal - runner: ubuntu-20.04 - image: docker://ubuntu:20.04 - i386-go-version: none + go-dep-entry: golang (>=1.16) + go-dep-package-name: golang + - target: jammy + go-dep-entry: golang (>=1.16) + go-dep-package-name: golang name: create-ppa - runs-on: ${{ matrix.runner }} - + runs-on: ubuntu-20.04 steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Metadata + id: metadata + run: | + echo "::set-output name=date::$(date +"%a, %d %b %Y %T %z")" + - name: Determine version uses: actions/github-script@v6 id: version @@ -50,21 +48,6 @@ jobs: throw "ERROR: unable to determine tag" } return tag.replace(/^v/, ''); - - name: Checkout code - uses: actions/checkout@v3 - - - name: Metadata - id: metadata - run: | - echo "::set-output name=date::$(date +"%a, %d %b %Y %T %z")" - - - name: Install packaging tools - run: | - sudo apt-get update - sudo apt-get install software-properties-common -y - sudo add-apt-repository ppa:longsleep/golang-backports -y - sudo apt-get update - sudo apt-get install gnupg dput dh-make devscripts lintian golang -y - name: Fill debian/* uses: cschleiden/replace-tokens@v1 @@ -74,7 +57,7 @@ jobs: tokenSuffix: '}}' env: ARCH: "any" - I386_GO_VERSION: ${{matrix.i386-go-version}} + GO_DEP_ENTRY: ${{matrix.go-dep-entry}} PACKAGE_NAME: "pack-cli" UBUNTU_VERSION: ${{ matrix.target }} HOMEPAGE: "https://buildpacks.io" @@ -85,44 +68,71 @@ jobs: MAINTAINER_NAME: "cncf-buildpacks" MAINTAINER_EMAIL: "cncf-buildpacks-maintainers@lists.cncf.io" - - name: Create PPA - run: ./.github/workflows/scripts/create_ppa.sh + ### + # NOTE: 'uses' does not suport interpolation so we have to manually define the + # followins steps per variant. + ### + + ### + # CREATE + ### + - name: Create PPA bionic + if: matrix.target == 'bionic' + uses: docker://ubuntu:bionic + with: + entrypoint: .github/workflows/delivery/ubuntu/build-create-ppa.sh env: - PACKAGE_NAME: "pack-cli" PACKAGE_VERSION: ${{ steps.version.outputs.result }} - MAINTAINER: "cncf-buildpacks" - MAINTANER_EMAIL: "cncf-buildpacks-maintainers@lists.cncf.io" GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }} - - name: Test Xenial - if: matrix.target == 'xenial' - uses: docker://ubuntu:16.04 + - name: Create PPA focal + if: matrix.target == 'focal' + uses: docker://ubuntu:focal + with: + entrypoint: .github/workflows/delivery/ubuntu/build-create-ppa.sh env: - PACKAGE_NAME: "pack-cli" + PACKAGE_VERSION: ${{ steps.version.outputs.result }} + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }} + + - name: Create PPA jammy + if: matrix.target == 'jammy' + uses: docker://ubuntu:jammy with: - entrypoint: .github/workflows/delivery/ubuntu/test-install-package.sh + entrypoint: .github/workflows/delivery/ubuntu/build-create-ppa.sh + env: + PACKAGE_VERSION: ${{ steps.version.outputs.result }} + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }} - - name: Test Bionic + ### + # TEST + ### + - name: Test bionic if: matrix.target == 'bionic' - uses: docker://ubuntu:18.04 - env: - PACKAGE_NAME: "pack-cli" + uses: docker://ubuntu:bionic with: entrypoint: .github/workflows/delivery/ubuntu/test-install-package.sh + env: + GO_DEP_PACKAGE_NAME: ${{matrix.go-dep-package-name}} - - name: Test Focal + - name: Test focal if: matrix.target == 'focal' - uses: docker://ubuntu:20.04 + uses: docker://ubuntu:focal + with: + entrypoint: .github/workflows/delivery/ubuntu/test-install-package.sh env: - PACKAGE_NAME: "pack-cli" + GO_DEP_PACKAGE_NAME: ${{matrix.go-dep-package-name}} + + - name: Test jammy + if: matrix.target == 'jammy' + uses: docker://ubuntu:jammy with: entrypoint: .github/workflows/delivery/ubuntu/test-install-package.sh + env: + GO_DEP_PACKAGE_NAME: ${{matrix.go-dep-package-name}} - name: Upload run: | - dput "${PPA_DEST}" ./../*.changes - env: - PPA_DEST: "ppa:cncf-buildpacks/pack-cli" - - + dput "ppa:cncf-buildpacks/pack-cli" ./../*.changes diff --git a/.github/workflows/scripts/create_ppa.sh b/.github/workflows/delivery/ubuntu/build-create-ppa.sh similarity index 78% rename from .github/workflows/scripts/create_ppa.sh rename to .github/workflows/delivery/ubuntu/build-create-ppa.sh index 40d786861..8b348cf72 100755 --- a/.github/workflows/scripts/create_ppa.sh +++ b/.github/workflows/delivery/ubuntu/build-create-ppa.sh @@ -4,15 +4,23 @@ set -e set -o pipefail readonly PROG_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -readonly PACK_DIR="$(cd "${PROG_DIR}/../../.." && pwd)" +readonly PACKAGE_NAME="pack-cli" +readonly MAINTAINER="cncf-buildpacks" +readonly MAINTANER_EMAIL="cncf-buildpacks-maintainers@lists.cncf.io" # verify the following are set. : "$PACKAGE_VERSION" -: "$PACKAGE_NAME" : "$GITHUB_WORKSPACE" -function main() { +function dependencies() { + apt-get update + apt-get install software-properties-common -y + add-apt-repository ppa:longsleep/golang-backports -y + apt-get update + apt-get install gnupg dput dh-make devscripts lintian golang -y +} +function main() { # import secrets needed to sign packages we build with debuild import_gpg @@ -29,7 +37,7 @@ function main() { dh_make -p "${PACKAGE_NAME}_${PACKAGE_VERSION}" --single --native --copyright apache --email "${MAINTAINER_EMAIL}" -y # copy our templated configuration files. - cp "$PACK_DIR/.github/workflows/delivery/ubuntu/debian/"* debian/ + cp "$PROG_DIR/debian/"* debian/ echo "compat" cat debian/compat @@ -58,7 +66,6 @@ function main() { # build a source based debian package, Ubuntu ONLY accepts source packages. debuild -S - } # import gpg keys from env @@ -71,4 +78,5 @@ function import_gpg() { gpg --allow-secret-key-import --import <(echo "$GPG_PRIVATE_KEY") } +dependencies main diff --git a/.github/workflows/delivery/ubuntu/debian/control b/.github/workflows/delivery/ubuntu/debian/control index 48aa48ba3..ee889170a 100644 --- a/.github/workflows/delivery/ubuntu/debian/control +++ b/.github/workflows/delivery/ubuntu/debian/control @@ -2,7 +2,7 @@ Source: {{PACKAGE_NAME}} Section: utils Priority: optional Maintainer: {{MAINTAINER_NAME}} <{{MAINTAINER_EMAIL}}> -Build-Depends: debhelper (>=9), git, golang (>=1.16) [!i386], golang-{{I386_GO_VERSION}} [i386] +Build-Depends: debhelper (>=9), git, {{GO_DEP_ENTRY}} Standards-Version: 3.9.8 Vcs-Git: git@github.com/{{REPO}}.git Vcs-Browser: https://github.com/{{REPO}} diff --git a/.github/workflows/delivery/ubuntu/test-install-package.sh b/.github/workflows/delivery/ubuntu/test-install-package.sh index 3c258f4bd..3c762feff 100755 --- a/.github/workflows/delivery/ubuntu/test-install-package.sh +++ b/.github/workflows/delivery/ubuntu/test-install-package.sh @@ -2,7 +2,11 @@ set -e set -o pipefail +# verify the following are set. +: "$GO_DEP_PACKAGE_NAME" + apt-get update + # install neede packaging utilities DEBIAN_FRONTEND=noninteractive apt-get install git devscripts debhelper software-properties-common -y @@ -18,7 +22,7 @@ pushd $testdir # install golang using ppa add-apt-repository ppa:longsleep/golang-backports -y apt-get update -apt-get install golang -y +apt-get install $GO_DEP_PACKAGE_NAME -y # build a debian binary package debuild -b -us -uc @@ -27,6 +31,6 @@ debuild -b -us -uc dpkg -i ../*.deb # list contents installed by the build debain package -dpkg -L ${PACKAGE_NAME} +dpkg -L pack-cli popd