This repository has been archived by the owner on Oct 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use GitHub Actions to automatically publish releases (#58)
- Loading branch information
Showing
5 changed files
with
79 additions
and
64 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Publish | ||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- 'v*' | ||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install python dependencies | ||
run: sudo apt-get update && sudo apt-get install -y python3-setuptools python3-pip | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Please build | ||
run: ./pleasew build //... | ||
|
||
- name: Create pre-release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: ./pleasew run //scripts:pre-release |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
for script in glob(["*.sh"]): | ||
sh_binary( | ||
name=basename(splitext(script)[0]), | ||
main=script, | ||
) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,29 @@ | ||
#!/bin/bash -e | ||
#!/bin/bash | ||
set -eo pipefail | ||
|
||
version="$1" | ||
|
||
if [ -z "${version}" ]; then | ||
echo "missing version" | ||
exit 1 | ||
if [ -n "${DOCKERHUB_USERNAME}" ]; then | ||
echo "${DOCKERHUB_PASSWORD}" | docker login --username "${DOCKERHUB_USERNAME}" --password-stdin | ||
fi | ||
|
||
# Build all images | ||
plz query alltargets //... --include docker-build | sed 's/$/_load/g' | plz -p -v 2 --colour run sequential | ||
version=$(git describe --always) | ||
|
||
docker_rules=$(./pleasew query alltargets --include docker-build //...) | ||
|
||
# Push image tags | ||
plz query alltargets //... --include docker-build | sed 's/$/_push/g' | plz -p -v 2 --colour run sequential | ||
fqns_to_push=() | ||
|
||
# Get all image tags | ||
plz query alltargets //... --include docker-build | sed 's/$/_fqn/g' | plz -p -v 2 --colour build | ||
all_tag_files=$(find . -type f -name "*_fqn" -not -name '.target_*' | grep -v metadata) | ||
all_tags="" | ||
for tag_file in ${all_tag_files}; do | ||
tag=$(cat ${tag_file}) | ||
all_tags+=" ${tag}" | ||
export DOCKER_BUILDKIT=1 | ||
for rule in ${docker_rules}; do | ||
./pleasew run "${rule}_load" | ||
fqn=$(cat $(./pleasew build "${rule}_fqn" | tail -n1 | tr -s " ")) | ||
repo="$(echo "${fqn}" | cut -f1 -d\:)" | ||
fqn_version="${repo}:${version}" | ||
echo "" | ||
echo "-> tagging as ${fqn_version}" | ||
docker tag "${fqn}" "${fqn_version}" | ||
fqns_to_push+=("${fqn_version}") | ||
done | ||
|
||
# Retag as version and push | ||
for tag in ${all_tags}; do | ||
repository=$(echo "${tag}" | cut -f1 -d":") | ||
new_tag="${repository}:${version}" | ||
docker tag "${tag}" "${new_tag}" | ||
echo "tagged ${new_tag}" | ||
docker push "${new_tag}" | ||
for fqn_to_push in "${fqns_to_push[@]}"; do | ||
echo "-> pushing as ${fqn_to_push}" | ||
docker push "${fqn_to_push}" | ||
done |