Skip to content

Commit b4bc5ec

Browse files
committed
draft
1 parent 8075c09 commit b4bc5ec

File tree

8 files changed

+193
-3
lines changed

8 files changed

+193
-3
lines changed

.github/workflows/nightly.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Nightly Release
2+
3+
on:
4+
workflow_dispatch: # Manual trigger
5+
schedule:
6+
- cron: '0 5 * * *' # 5 AM UTC = Midnight EST
7+
pull_request:
8+
9+
jobs:
10+
nightly:
11+
if: ${{ github.repository == 'liangyuanpeng/triggers' }}
12+
runs-on: ubuntu-latest
13+
permissions:
14+
id-token: write # To be able to get OIDC ID token to sign images.
15+
contents: write # To be able to update releases.
16+
packages: write # To be able to push images and signatures.
17+
18+
env:
19+
IMAGE_HOST: ghcr.io
20+
IMAGE_NAMESPACE: ${{ github.repository }}
21+
22+
steps:
23+
- uses: actions/checkout@v3
24+
- uses: actions/setup-go@v4
25+
with:
26+
go-version: '1.19.x'
27+
check-latest: true
28+
29+
# Install tools
30+
- uses: ko-build/[email protected]
31+
with:
32+
version: v0.13.0
33+
- uses: imjasonh/setup-crane@e82f1b9a8007d399333baba4d75915558e9fb6a4
34+
- uses: sigstore/cosign-installer@v3
35+
36+
- name: Get current date
37+
id: date
38+
run: echo "date=$(date +'%Y-%m-%d-%s')" >> $GITHUB_OUTPUT
39+
40+
- name: Generate and upload release YAMLs
41+
env:
42+
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
43+
REGISTRY_USERNAME: ${{ github.repository_owner }}
44+
TAG: "nightly-${{ steps.date.outputs.date }}"
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
run: |
47+
make release
48+
49+
mv release.yaml nightly-${{ steps.date.outputs.date }}.yaml
50+
mv release-debug.yaml nightly-${{ steps.date.outputs.date }}-debug.yaml
51+
# gh release upload nightly nightly-${{ steps.date.outputs.date }}.yaml
52+
# gh release upload nightly nightly-${{ steps.date.outputs.date }}-debug.yaml
53+
54+
- name: Update latest tag of supporting images
55+
run: |
56+
crane copy "${IMAGE_HOST}/${IMAGE_NAMESPACE}/triggers:nightly-${{ steps.date.outputs.date }}" "${IMAGE_HOST}/${IMAGE_NAMESPACE}/triggers:latest"
57+
58+
- name: Sign released images
59+
run: |
60+
for f in \
61+
nightly-${{ steps.date.outputs.date }}.yaml \
62+
nightly-${{ steps.date.outputs.date }}-debug.yaml; do
63+
grep -o "ghcr.io[^\"]*" $f | xargs cosign sign --yes \
64+
-a sha=${{ github.sha }} \
65+
-a run_id=${{ github.run_id }} \
66+
-a run_attempt=${{ github.run_attempt }}
67+
done

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ $(CONTROLLER_GEN):
7474
.PHONY: manifests
7575
manifests: controller-gen
7676
$(CONTROLLER_GEN) \
77-
rbac:roleName=shipwright-trigger crd paths="./..." \
78-
output:dir=$(MANIFEST_DIR)
77+
rbac:roleName=shipwright-triggers webhook paths="./..." \
78+
output:dir=deploy/
79+
mv deploy/role.yaml deploy/200-role.yaml
7980

8081
# runs the manager from your host
8182
.PHONY: run
@@ -99,6 +100,9 @@ deploy:
99100
$(CHART_DIR) | \
100101
ko apply $(KO_OPTS) $(ARGS) --filename -
101102

103+
release: manifests
104+
hack/release.sh
105+
102106
# runs the unit tests, with optional arguments
103107
.PHONY: test-unit
104108
test-unit: CGO_ENABLED=1

deploy/100-namespace.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
apiVersion: v1
3+
kind: Namespace
4+
metadata:
5+
name: shipwright-build

chart/generated/role.yaml renamed to deploy/200-role.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1
33
kind: ClusterRole
44
metadata:
55
creationTimestamp: null
6-
name: shipwright-trigger
6+
name: shipwright-triggers
77
rules:
88
- apiGroups:
99
- shipwright.io

deploy/300-rolebinding.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
kind: ClusterRoleBinding
3+
apiVersion: rbac.authorization.k8s.io/v1
4+
metadata:
5+
name: shipwright-triggers
6+
subjects:
7+
- kind: ServiceAccount
8+
name: shipwright-triggers
9+
namespace: shipwright-build
10+
roleRef:
11+
kind: ClusterRole
12+
name: shipwright-triggers
13+
apiGroup: rbac.authorization.k8s.io
14+
15+
---
16+
kind: RoleBinding
17+
apiVersion: rbac.authorization.k8s.io/v1
18+
metadata:
19+
name: shipwright-triggers
20+
namespace: shipwright-build
21+
subjects:
22+
- kind: ServiceAccount
23+
name: shipwright-triggers
24+
namespace: shipwright-build
25+
roleRef:
26+
kind: Role
27+
name: shipwright-triggers
28+
apiGroup: rbac.authorization.k8s.io

deploy/400-serviceaccount.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: shipwright-triggers
6+
namespace: shipwright-build

deploy/500-controller.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: shipwright-triggers
6+
namespace: shipwright-build
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
name: shipwright-triggers
12+
template:
13+
metadata:
14+
labels:
15+
name: shipwright-triggers
16+
spec:
17+
serviceAccountName: shipwright-triggers
18+
containers:
19+
- name: shipwright-trigger
20+
image: ko://github.com/shipwright-io/triggers
21+
env:
22+
- name: WATCH_NAMESPACE
23+
valueFrom:
24+
fieldRef:
25+
fieldPath: metadata.namespace
26+
- name: BUILD_CONTROLLER_LEADER_ELECTION_NAMESPACE
27+
valueFrom:
28+
fieldRef:
29+
fieldPath: metadata.namespace
30+
- name: POD_NAME
31+
valueFrom:
32+
fieldRef:
33+
fieldPath: metadata.name
34+
- name: CONTROLLER_NAME
35+
value: "shipwright-build"
36+
- name: GIT_ENABLE_REWRITE_RULE
37+
value: "false"
38+
ports:
39+
- containerPort: 8080
40+
name: metrics-port
41+
livenessProbe:
42+
httpGet:
43+
path: /metrics
44+
port: metrics-port
45+
initialDelaySeconds: 5
46+
periodSeconds: 10
47+
readinessProbe:
48+
httpGet:
49+
path: /metrics
50+
port: metrics-port
51+
initialDelaySeconds: 5
52+
periodSeconds: 10

hack/release.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
# Copyright The Shipwright Contributors
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
7+
set -euo pipefail
8+
9+
GO_FLAGS=${GO_FLAGS:-""}
10+
11+
echo "Logging into container registry $IMAGE_HOST"
12+
echo "$REGISTRY_PASSWORD" | ko login -u "$REGISTRY_USERNAME" --password-stdin "$IMAGE_HOST"
13+
14+
echo "Building container image"
15+
16+
echo "Adding io.shipwright.vcs-ref label with value: ${GITHUB_SHA}"
17+
18+
KO_DOCKER_REPO="${IMAGE_HOST}/${IMAGE_NAMESPACE}" GOFLAGS="${GO_FLAGS}" ko resolve \
19+
--base-import-paths \
20+
--tags "${TAG}" \
21+
--image-label "io.shipwright.vcs-ref=${GITHUB_SHA}" \
22+
--platform=all -R -f deploy/ > release.yaml
23+
24+
KO_DOCKER_REPO="${IMAGE_HOST}/${IMAGE_NAMESPACE}" GOFLAGS="${GO_FLAGS} -tags=pprof_enabled" ko resolve \
25+
--base-import-paths \
26+
--tags "${TAG}-debug" \
27+
--image-label "io.shipwright.vcs-ref=${GITHUB_SHA}" \
28+
--platform=all -R -f deploy/ > release-debug.yaml

0 commit comments

Comments
 (0)