Commit fc597f4 1 parent f1ffc67 commit fc597f4 Copy full SHA for fc597f4
File tree 5 files changed +58
-5
lines changed
5 files changed +58
-5
lines changed Original file line number Diff line number Diff line change 27
27
runs-on : ubuntu-latest
28
28
# exclusive with ci3-external.yml: if it is a pull request target only run if it is NOT a fork.
29
29
if : github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
30
+ environment : ${{ startsWith(github.ref, 'refs/tags/v') && 'master' || '' }}
30
31
strategy :
31
32
fail-fast : false
32
33
matrix :
Original file line number Diff line number Diff line change @@ -48,9 +48,6 @@ ssh $ssh_args -F build_instance_ssh_config ubuntu@$ip '
48
48
mkdir .aws
49
49
'
50
50
51
- # Copy aws credentials onto machine.
52
- scp -F build_instance_ssh_config $HOME /.aws/build_instance_credentials ubuntu@$ip :.aws/credentials
53
-
54
51
# Download crs onto machine.
55
52
ssh $ssh_args -F build_instance_ssh_config ubuntu@$ip < ../../barretenberg/scripts/download_bb_crs.sh
56
53
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ PRICE=$(jq -n "$BID_PER_CPU_HOUR*$CPUS*100000 | round / 100000")
53
53
launch_spec=$( cat << EOF
54
54
{
55
55
"ImageId": "$AMI ",
56
- "KeyName": "build-instance",
56
+ "KeyName": "${KEY_NAME :- build-instance} ",
57
57
"SecurityGroupIds": ["sg-0ccd4e5df0dcca0c9"],
58
58
"InstanceType": "$INSTANCE_TYPE ",
59
59
"BlockDeviceMappings": [
Original file line number Diff line number Diff line change 45
45
instance_name=$( echo -n " $REF_NAME " | head -c 50 | tr -c ' a-zA-Z0-9-' ' _' ) _$arch
46
46
fi
47
47
48
+ if semver check $REF_NAME ; then
49
+ # Override the public key that aws will load into ~/.ssh/authorized_keys on the launched instance.
50
+ # This requires the restricted key only available in release environments.
51
+ key_name=" super-build-instance"
52
+ else
53
+ key_name=" build-instance"
54
+ fi
55
+
48
56
[ -n " ${INSTANCE_POSTFIX:- } " ] && instance_name+=" _$INSTANCE_POSTFIX "
49
57
50
58
echo_header " request build instance"
@@ -60,13 +68,24 @@ if [ -n "$existing_instance" ]; then
60
68
fi
61
69
62
70
# Request new instance.
63
- ip_sir=$( aws_request_instance $instance_name $cores $arch )
71
+ ip_sir=$( KEY_NAME= $key_name aws_request_instance $instance_name $cores $arch )
64
72
IFS=' :' read -r -a parts <<< " $ip_sir"
65
73
ip=" ${parts[0]} "
66
74
sir=" ${parts[1]} "
67
75
iid=" ${parts[2]} "
68
76
trap on_exit EXIT
69
77
78
+ # If AWS credentials are not set, try to load them from ~/.aws/build_instance_credentials.
79
+ if [ -z " ${AWS_ACCESS_KEY_ID:- } " ] || [ -z " ${AWS_SECRET_ACCESS_KEY:- } " ]; then
80
+ if [ ! -f ~ /.aws/build_instance_credentials ]; then
81
+ echo " No aws credentials found in env or ~/.aws/build_instance_credentials."
82
+ exit 1
83
+ fi
84
+ echo " AWS credentials are being set from ~/.aws/build_instance_credentials."
85
+ export AWS_ACCESS_KEY_ID=$( grep aws_access_key_id ~ /.aws/build_instance_credentials | awk ' {print $3}' )
86
+ export AWS_SECRET_ACCESS_KEY=$( grep aws_secret_access_key ~ /.aws/build_instance_credentials | awk ' {print $3}' )
87
+ fi
88
+
70
89
# If we're asking to not terminate the instance automatically, we also don't want to remove the container.
71
90
[ " $NO_TERMINATE " -eq 0 ] && docker_args+=" --rm"
72
91
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # Set your GitHub repository info and token if needed
3
+ GH_OWNER=" aztecprotocol"
4
+ GH_REPO=" aztec-packages"
5
+
6
+ # Fetch all releases with pagination
7
+ page=1
8
+ per_page=100
9
+ all_releases=" "
10
+
11
+ while true ; do
12
+ page_releases=$( curl -s " https://api.github.com/repos/$GH_OWNER /$GH_REPO /releases?per_page=$per_page &page=$page " | jq -r ' .[].tag_name' )
13
+
14
+ # Break if no more releases are found
15
+ if [ -z " $page_releases " ]; then
16
+ break
17
+ fi
18
+
19
+ all_releases=" $all_releases $page_releases "
20
+ page=$(( page + 1 ))
21
+ done
22
+ # echo "${all_releases[@]}"
23
+
24
+ # Create an associative array for fast lookup
25
+ declare -A release_tags
26
+ for tag in $all_releases ; do
27
+ release_tags[" $tag " ]=1
28
+ done
29
+
30
+ # List remote tags and delete those not found in releases
31
+ for tag in $( git ls-remote --tags origin | awk ' {print $2}' | sed ' s|refs/tags/||' ) ; do
32
+ if [ -z " ${release_tags[$tag]} " ]; then
33
+ echo " Deleting remote tag: $tag "
34
+ git push --delete origin tag " $tag "
35
+ fi
36
+ done
You can’t perform that action at this time.
0 commit comments