Build #61
This file contains 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: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
schedule: | |
- cron: '0 1 * * *' | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Build Skopeo | |
id: build_skopeo | |
run: | | |
set -eux | |
APP=skopeo | |
APP_VERSION=$(cat version.txt) | |
APP_REPO="https://github.com/containers/skopeo.git" | |
ADD_TAG="" | |
tags="$(git ls-remote --tags $APP_REPO | grep 'v[1-9]\.[0-9]*\.[0-9]*$' | awk -F'tags/' '{print $2}' | sort -t. -k1,1n -k2,2n -k3,3n)" | |
new_tags="$(printf "%s" "$tags"| sed -n '{/\.0$/{g;p}};h' | tail -4) $(printf "%s" "$tags" | tail -1)" | |
echo "::debug::[Tags] $new_tags" | |
# golang:1.20-alpine3.16 | |
build_image="golang:1.20-alpine3.16" | |
docker pull "${build_image}" | |
for t in $new_tags; do | |
echo "[check] $t" | |
b=$(echo "${APP_VERSION}" | grep -w ${t} | wc -l) | |
if [[ $b == 0 ]]; then | |
echo "::group::[Build] $t" | |
git clone -q --depth=1 --branch $t --progress $APP_REPO | |
pushd ${APP} | |
git checkout -b $t $t | |
git branch | |
# Linux builds | |
docker run --rm -t -v $PWD:/build "${build_image}" sh -c "apk update && apk add gpgme btrfs-progs-dev llvm13-dev gcc musl-dev && cd /build && CGO_ENABLE=0 GO111MODULE=on GOOS=linux GOARCH=amd64 go build -mod=vendor '-buildmode=pie' -ldflags '-extldflags -static' -gcflags '' -tags 'exclude_graphdriver_devicemapper exclude_graphdriver_btrfs containers_image_openpgp' -o ./bin/skopeo-linux-amd64 ./cmd/skopeo && md5sum ./bin/skopeo-linux-amd64 > ./bin/skopeo-linux-amd64.md5 && sha256sum ./bin/skopeo-linux-amd64 > ./bin/skopeo-linux-amd64.sha256" | |
docker run --rm -t -v $PWD:/build "${build_image}" sh -c "apk update && apk add gpgme btrfs-progs-dev llvm13-dev gcc musl-dev && cd /build && CGO_ENABLE=0 GO111MODULE=on GOOS=linux GOARCH=arm64 go build -mod=vendor '-buildmode=pie' -ldflags '-extldflags -static' -gcflags '' -tags 'exclude_graphdriver_devicemapper exclude_graphdriver_btrfs containers_image_openpgp' -o ./bin/skopeo-linux-arm64 ./cmd/skopeo && md5sum ./bin/skopeo-linux-arm64 > ./bin/skopeo-linux-arm64.md5 && sha256sum ./bin/skopeo-linux-arm64 > ./bin/skopeo-linux-arm64.sha256" | |
docker run --rm -t -v $PWD:/build "${build_image}" sh -c "apk update && apk add gpgme btrfs-progs-dev llvm13-dev gcc musl-dev && cd /build && CGO_ENABLE=0 GO111MODULE=on GOOS=linux GOARCH=ppc64le go build -mod=vendor '-buildmode=pie' -ldflags '-extldflags -static' -gcflags '' -tags 'exclude_graphdriver_devicemapper exclude_graphdriver_btrfs containers_image_openpgp' -o ./bin/skopeo-linux-ppc64le ./cmd/skopeo && md5sum ./bin/skopeo-linux-ppc64le > ./bin/skopeo-linux-ppc64le.md5 && sha256sum ./bin/skopeo-linux-ppc64le > ./bin/skopeo-linux-ppc64le.sha256" | |
# Darwin builds | |
docker run --rm -t -v $PWD:/build "${build_image}" sh -c "apk update && apk add gpgme btrfs-progs-dev llvm13-dev gcc musl-dev && cd /build && CGO_ENABLE=0 GO111MODULE=on GOOS=darwin GOARCH=amd64 go build -mod=vendor -gcflags '' -tags 'exclude_graphdriver_devicemapper exclude_graphdriver_btrfs containers_image_openpgp' -o ./bin/skopeo-darwin-amd64 ./cmd/skopeo && md5sum ./bin/skopeo-darwin-amd64 > ./bin/skopeo-darwin-amd64.md5 && sha256sum ./bin/skopeo-darwin-amd64 > ./bin/skopeo-darwin-amd64.sha256" | |
docker run --rm -t -v $PWD:/build "${build_image}" sh -c "apk update && apk add gpgme btrfs-progs-dev llvm13-dev gcc musl-dev && cd /build && CGO_ENABLE=0 GO111MODULE=on GOOS=darwin GOARCH=arm64 go build -mod=vendor -gcflags '' -tags 'exclude_graphdriver_devicemapper exclude_graphdriver_btrfs containers_image_openpgp' -o ./bin/skopeo-darwin-arm64 ./cmd/skopeo && md5sum ./bin/skopeo-darwin-arm64 > ./bin/skopeo-darwin-arm64.md5 && sha256sum ./bin/skopeo-darwin-arm64 > ./bin/skopeo-darwin-arm64.sha256" | |
ls -al bin/ | |
cd ../ | |
ls -al ./ | |
ADD_TAG=$t | |
echo "::debug::[Push file]" | |
echo "${t}" >> version.txt | |
git config --global user.email "scalr@scalr.io" | |
git config --global user.name "scalr" | |
git config --global --add safe.directory /github/workspace | |
git add version.txt | |
git commit -m "$APP $ADD_TAG (Github Actions Automatically Built in `date +"%Y-%m-%d %H:%M"`)" | |
echo "ADD_TAG=${ADD_TAG}" >> $GITHUB_OUTPUT | |
cat ./skopeo/bin/skopeo-{darwin,linux}-{amd64,arm64}.{md5,sha256} > CHECKSUMS.txt | |
cat ./skopeo/bin/skopeo-linux-ppc64le.{md5,sha256} >> CHECKSUMS.txt | |
echo "::endgroup::" | |
popd | |
break | |
else | |
echo "::debug::[skip] $t" | |
fi | |
done | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
if: ${{ steps.build_skopeo.outputs.ADD_TAG != '' }} | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref }} | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
if: ${{ steps.build_skopeo.outputs.ADD_TAG != '' }} | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag_name: "${{ steps.build_skopeo.outputs.ADD_TAG }}" | |
files: | | |
./skopeo/bin/skopeo-linux-amd64 | |
./skopeo/bin/skopeo-linux-amd64.md5 | |
./skopeo/bin/skopeo-linux-amd64.sha256 | |
./skopeo/bin/skopeo-linux-arm64 | |
./skopeo/bin/skopeo-linux-arm64.md5 | |
./skopeo/bin/skopeo-linux-arm64.sha256 | |
./skopeo/bin/skopeo-linux-ppc64le | |
./skopeo/bin/skopeo-linux-ppc64le.md5 | |
./skopeo/bin/skopeo-linux-ppc64le.sha256 | |
./skopeo/bin/skopeo-darwin-amd64 | |
./skopeo/bin/skopeo-darwin-amd64.md5 | |
./skopeo/bin/skopeo-darwin-amd64.sha256 | |
./skopeo/bin/skopeo-darwin-arm64 | |
./skopeo/bin/skopeo-darwin-arm64.md5 | |
./skopeo/bin/skopeo-darwin-arm64.sha256 | |
body_path: ./CHECKSUMS.txt |