Skip to content

Commit 5a35f5c

Browse files
committed
Fix chart release process (#24)
- Always use bash shell in release workflow - Only update timestamp for new charts - Update chart repo index.yaml in pr - Make commit and pr subject repo agnostic Signed-off-by: Tamal Saha <tamal@appscode.com>
1 parent 6b491ca commit 5a35f5c

File tree

2 files changed

+166
-104
lines changed

2 files changed

+166
-104
lines changed

.github/workflows/ci.yml

Lines changed: 66 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -3,97 +3,88 @@ name: CI
33
on:
44
pull_request:
55
branches:
6-
- '*'
6+
- "*"
77
push:
88
branches:
99
- master
1010

1111
jobs:
12-
1312
build:
1413
name: Build
1514
runs-on: ubuntu-latest
1615
steps:
16+
- name: Set up Go 1.14
17+
uses: actions/setup-go@v1
18+
with:
19+
go-version: 1.14
20+
id: go
1721

18-
- name: Set up Go 1.14
19-
uses: actions/setup-go@v1
20-
with:
21-
go-version: 1.14
22-
id: go
23-
24-
- name: Check out code into the Go module directory
25-
uses: actions/checkout@v1
22+
- uses: actions/checkout@v1
2623

27-
- name: Set up Docker Buildx
28-
id: buildx
29-
uses: crazy-max/ghaction-docker-buildx@v1
30-
with:
31-
buildx-version: latest
32-
qemu-version: latest
24+
- name: Set up Docker Buildx
25+
id: buildx
26+
uses: crazy-max/ghaction-docker-buildx@v1
27+
with:
28+
buildx-version: latest
29+
qemu-version: latest
3330

34-
- name: Available platforms
35-
run: echo ${{ steps.buildx.outputs.platforms }}
31+
- name: Available platforms
32+
run: echo ${{ steps.buildx.outputs.platforms }}
3633

37-
- name: Prepare Host
38-
run: |
39-
sudo apt-get -qq update || true
40-
sudo apt-get install -y bzr
41-
# install yq
42-
curl -fsSL -o yq https://github.com/mikefarah/yq/releases/download/3.3.0/yq_linux_amd64
43-
chmod +x yq
44-
sudo mv yq /usr/local/bin/yq
45-
# install kubectl
46-
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.17.0/bin/linux/amd64/kubectl
47-
chmod +x ./kubectl
48-
sudo mv ./kubectl /usr/local/bin/kubectl
34+
- name: Prepare Host
35+
run: |
36+
sudo apt-get -qq update || true
37+
sudo apt-get install -y bzr
38+
# install yq
39+
curl -fsSL -o yq https://github.com/mikefarah/yq/releases/download/3.3.0/yq_linux_amd64
40+
chmod +x yq
41+
sudo mv yq /usr/local/bin/yq
42+
# install kubectl
43+
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.17.0/bin/linux/amd64/kubectl
44+
chmod +x ./kubectl
45+
sudo mv ./kubectl /usr/local/bin/kubectl
4946
50-
- name: Run checks
51-
run: |
52-
make ci
47+
- name: Run checks
48+
run: |
49+
make ci
5350
54-
- name: Build
55-
env:
56-
REGISTRY: appscodeci
57-
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
58-
USERNAME: 1gtm
59-
run: |
60-
docker login --username ${USERNAME} --password ${DOCKER_TOKEN}
61-
make push
51+
- name: Build
52+
env:
53+
REGISTRY: appscodeci
54+
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
55+
USERNAME: 1gtm
56+
run: |
57+
docker login --username ${USERNAME} --password ${DOCKER_TOKEN}
58+
make push
6259
63-
- name: Create Kubernetes cluster
64-
id: kind
65-
uses: engineerd/setup-kind@v0.1.0
66-
with:
67-
version: v0.7.0
68-
config: hack/kubernetes/kind.yaml
60+
- name: Create Kubernetes cluster
61+
id: kind
62+
uses: engineerd/setup-kind@v0.3.0
63+
with:
64+
version: v0.8.1
65+
config: hack/kubernetes/kind.yaml
6966

70-
- name: Prepare cluster for testing
71-
id: local-path
72-
env:
73-
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
74-
USERNAME: 1gtm
75-
REGISTRY_SECRET: regcred
76-
run: |
77-
echo "waiting for nodes to be ready ..."
78-
kubectl wait --for=condition=Ready nodes --all --timeout=5m
79-
kubectl get nodes
80-
echo
81-
echo "installing local-path provisioner ..."
82-
kubectl delete storageclass --all
83-
kubectl apply -f https://github.com/rancher/local-path-provisioner/raw/v0.0.12/deploy/local-path-storage.yaml
84-
kubectl wait --for=condition=Ready pods -n local-path-storage --all --timeout=5m
85-
kubectl apply -f hack/kubernetes/storageclass/standard.yaml
86-
echo
87-
echo "create docker-registry secret"
88-
kubectl create secret docker-registry ${REGISTRY_SECRET} --namespace=kube-system --docker-server=https://index.docker.io/v1/ --docker-username=${USERNAME} --docker-password=${DOCKER_TOKEN}
67+
- name: Prepare cluster for testing
68+
id: local-path
69+
env:
70+
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
71+
USERNAME: 1gtm
72+
REGISTRY_SECRET: regcred
73+
run: |
74+
echo "waiting for nodes to be ready ..."
75+
kubectl wait --for=condition=Ready nodes --all --timeout=5m
76+
kubectl get nodes
77+
echo
78+
echo "create docker-registry secret"
79+
kubectl create secret docker-registry ${REGISTRY_SECRET} --namespace=kube-system --docker-server=https://index.docker.io/v1/ --docker-username=${USERNAME} --docker-password=${DOCKER_TOKEN}
8980
90-
- name: Install CRDs
91-
run: |
92-
kubectl apply -f https://github.com/stashed/apimachinery/raw/master/api/crds/stash.appscode.com_functions.yaml
93-
kubectl apply -f https://github.com/stashed/apimachinery/raw/master/api/crds/stash.appscode.com_tasks.yaml
94-
kubectl wait --for=condition=NamesAccepted crds --all --timeout=5m
81+
- name: Install CRDs
82+
run: |
83+
kubectl apply -f https://github.com/stashed/apimachinery/raw/master/crds/stash.appscode.com_functions.yaml
84+
kubectl apply -f https://github.com/stashed/apimachinery/raw/master/crds/stash.appscode.com_tasks.yaml
85+
kubectl wait --for=condition=NamesAccepted crds --all --timeout=5m
9586
96-
- name: Test charts
97-
run: |
98-
export KUBECONFIG=$HOME/.kube/config
99-
make ct
87+
- name: Test charts
88+
run: |
89+
export KUBECONFIG=$HOME/.kube/config
90+
make ct

.github/workflows/release.yml

Lines changed: 100 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,110 @@ name: Release
33
on:
44
push:
55
tags:
6-
- '*.*'
7-
- '*.*.*'
6+
- "*.*"
87

98
jobs:
10-
119
build:
1210
name: Build
1311
runs-on: ubuntu-latest
12+
defaults:
13+
run:
14+
shell: bash
1415
steps:
16+
- name: Check out code into the Go module directory
17+
uses: actions/checkout@v1
18+
19+
- name: Parse Parameters
20+
id: params
21+
run: |
22+
GIT_TAG=${GITHUB_REF#'refs/tags/'}
23+
echo ::set-output name=git_tag::$GIT_TAG
24+
while IFS=$': \t' read -r marker v; do
25+
case $marker in
26+
Release)
27+
echo ::set-output name=release::$v
28+
;;
29+
Release-tracker)
30+
echo ::set-output name=release_tracker::$v
31+
;;
32+
esac
33+
done < <(git tag -l --format='%(body)' $GIT_TAG)
34+
35+
- name: Install GitHub CLI
36+
run: |
37+
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
38+
sudo mv bin/hub /usr/local/bin
39+
40+
- name: Print version info
41+
id: semver
42+
run: |
43+
make version
44+
45+
- name: Set up Docker Buildx
46+
id: buildx
47+
uses: crazy-max/ghaction-docker-buildx@v1
48+
with:
49+
buildx-version: latest
50+
qemu-version: latest
51+
52+
- name: Available platforms
53+
run: echo ${{ steps.buildx.outputs.platforms }}
54+
55+
- name: Build
56+
env:
57+
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
58+
USERNAME: 1gtm
59+
APPSCODE_ENV: prod
60+
run: |
61+
docker login --username ${USERNAME} --password ${DOCKER_TOKEN}
62+
make release
63+
64+
- name: Clone charts repository
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.LGTM_GITHUB_TOKEN }}
67+
run: |
68+
cd $HOME
69+
git clone https://1gtm:${GITHUB_TOKEN}@github.com/appscode/charts.git
70+
cd charts
71+
git config user.name "1gtm"
72+
git config user.email "1gtm@appscode.com"
73+
74+
- name: Package
75+
run: |
76+
echo "install helm 3"
77+
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
78+
echo "package charts"
79+
find charts -maxdepth 1 -mindepth 1 -type d -exec helm package {} -d {} \;
80+
helm repo index --merge $HOME/charts/stable/index.yaml --url https://charts.appscode.com/stable/ charts
81+
mv charts/index.yaml $HOME/charts/stable/index.yaml
82+
cd charts
83+
find . -maxdepth 1 -mindepth 1 -type d -exec mkdir -p $HOME/charts/stable/{} \;
84+
find . -path ./charts -prune -o -name '*.tgz' -exec mv {} $HOME/charts/stable/{} \;
1585
16-
- name: Check out code into the Go module directory
17-
uses: actions/checkout@v1
18-
19-
- name: Print version info
20-
id: semver
21-
run: |
22-
make version
23-
24-
- name: Set up Docker Buildx
25-
id: buildx
26-
uses: crazy-max/ghaction-docker-buildx@v1
27-
with:
28-
buildx-version: latest
29-
qemu-version: latest
30-
31-
- name: Available platforms
32-
run: echo ${{ steps.buildx.outputs.platforms }}
33-
34-
- name: Build
35-
env:
36-
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
37-
USERNAME: 1gtm
38-
APPSCODE_ENV: prod
39-
run: |
40-
docker login --username ${USERNAME} --password ${DOCKER_TOKEN}
41-
make release
86+
- name: Create pull request
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.LGTM_GITHUB_TOKEN }}
89+
run: |
90+
pr_branch=${GITHUB_REPOSITORY}/${GITHUB_RUN_ID}
91+
cd $HOME/charts
92+
git checkout -b $pr_branch
93+
git add --all
94+
ct_cmd="git commit -a -s -m \"Publish $GITHUB_REPOSITORY@${{ steps.params.outputs.git_tag }} charts\""
95+
pr_cmd=$(cat <<EOF
96+
hub pull-request \
97+
--labels automerge \
98+
--message "Publish $GITHUB_REPOSITORY@${{ steps.params.outputs.git_tag }} charts"
99+
EOF
100+
)
101+
if [ ! -z ${{ steps.params.outputs.release }} ]; then
102+
ct_cmd="$ct_cmd --message \"Release: ${{ steps.params.outputs.release }}\""
103+
pr_cmd="$pr_cmd --message \"Release: ${{ steps.params.outputs.release }}\""
104+
fi
105+
if [ ! -z ${{ steps.params.outputs.release_tracker }} ]; then
106+
ct_cmd="$ct_cmd --message \"Release-tracker: ${{ steps.params.outputs.release_tracker }}\""
107+
pr_cmd="$pr_cmd --message \"Release-tracker: ${{ steps.params.outputs.release_tracker }}\""
108+
fi
109+
pr_cmd="$pr_cmd --message \"Signed-off-by: $(git config --get user.name) <$(git config --get user.email)>\""
110+
eval "$ct_cmd"
111+
git push -u origin HEAD -f
112+
eval "$pr_cmd"

0 commit comments

Comments
 (0)