Skip to content

Commit

Permalink
Fix chart release process (#38)
Browse files Browse the repository at this point in the history
- 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
- Add autorelease label if Release-tracker: is present commit body

Signed-off-by: Tamal Saha <tamal@appscode.com>
  • Loading branch information
tamalsaha committed Jun 14, 2020
1 parent bcd1a52 commit aa62d4a
Show file tree
Hide file tree
Showing 2 changed files with 147 additions and 103 deletions.
141 changes: 74 additions & 67 deletions .github/workflows/ci.yml
Expand Up @@ -3,94 +3,101 @@ name: CI
on:
pull_request:
branches:
- '*'
- "*"
push:
branches:
- master

jobs:

build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go

- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Check out code into the Go module directory
uses: actions/checkout@v1

- name: Prepare Host
run: |
sudo apt-get -qq update || true
sudo apt-get install -y bzr
# install yq
curl -fsSL -o yq https://github.com/mikefarah/yq/releases/download/3.3.0/yq_linux_amd64
chmod +x yq
sudo mv yq /usr/local/bin/yq
# install kubectl
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.17.0/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
- name: Prepare Host
run: |
sudo apt-get -qq update || true
sudo apt-get install -y bzr
# install yq
curl -fsSL -o yq https://github.com/mikefarah/yq/releases/download/3.3.0/yq_linux_amd64
chmod +x yq
sudo mv yq /usr/local/bin/yq
# install kubectl
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.17.0/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
- name: Run checks
run: |
make ci
- name: Run checks
run: |
make ci
kubernetes:
name: Kubernetes
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
k8s: [v1.11.10, v1.12.10, v1.13.12, v1.14.10, v1.15.7, v1.16.4, v1.17.2, v1.18.0]
k8s:
[
v1.11.10,
v1.12.10,
v1.13.12,
v1.14.10,
v1.15.7,
v1.16.4,
v1.17.2,
v1.18.0,
]
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v1

- name: Check out code into the Go module directory
uses: actions/checkout@v1

- name: Create Kubernetes ${{ matrix.k8s }} cluster
id: kind
uses: engineerd/setup-kind@v0.1.0
with:
version: v0.7.0
config: hack/kubernetes/kind.yaml
image: kindest/node:${{ matrix.k8s }}
- name: Create Kubernetes ${{ matrix.k8s }} cluster
id: kind
uses: engineerd/setup-kind@v0.1.0
with:
version: v0.7.0
config: hack/kubernetes/kind.yaml
image: kindest/node:${{ matrix.k8s }}

- name: Prepare cluster for testing
id: local-path
env:
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
USERNAME: 1gtm
REGISTRY_SECRET: regcred
run: |
echo "waiting for nodes to be ready ..."
kubectl wait --for=condition=Ready nodes --all --timeout=5m
kubectl get nodes
echo
kubectl version
echo
echo "create docker-registry secret"
kubectl create secret docker-registry ${REGISTRY_SECRET} --namespace=kube-system --docker-server=https://index.docker.io/v1/ --docker-username=${USERNAME} --docker-password=${DOCKER_TOKEN}
- name: Prepare cluster for testing
id: local-path
env:
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
USERNAME: 1gtm
REGISTRY_SECRET: regcred
run: |
echo "waiting for nodes to be ready ..."
kubectl wait --for=condition=Ready nodes --all --timeout=5m
kubectl get nodes
echo
kubectl version
echo
echo "create docker-registry secret"
kubectl create secret docker-registry ${REGISTRY_SECRET} --namespace=kube-system --docker-server=https://index.docker.io/v1/ --docker-username=${USERNAME} --docker-password=${DOCKER_TOKEN}
- name: Test vault-operator chart
run: |
export KUBECONFIG="${HOME}/.kube/config"
make ct TEST_CHARTS=charts/vault-operator
echo
kubectl delete crds --all
kubectl apply -f https://github.com/kubevault/operator/raw/master/api/crds/catalog.kubevault.com_vaultserverversions.yaml --validate=false
kubectl wait --for=condition=NamesAccepted crds --all --timeout=5m
make ct TEST_CHARTS=charts/vault-catalog
echo
kubectl delete crds --all
- name: Test vault-operator chart
run: |
export KUBECONFIG="${HOME}/.kube/config"
make ct TEST_CHARTS=charts/vault-operator
echo
kubectl delete crds --all
kubectl apply -f https://github.com/kubevault/operator/raw/master/api/crds/catalog.kubevault.com_vaultserverversions.yaml --validate=false
kubectl wait --for=condition=NamesAccepted crds --all --timeout=5m
make ct TEST_CHARTS=charts/vault-catalog
echo
kubectl delete crds --all
- name: Test csi-vault chart
if: (matrix.k8s != 'v1.11.10') && (matrix.k8s != 'v1.12.10') && (matrix.k8s != 'v1.13.12')
run: |
export KUBECONFIG="${HOME}/.kube/config"
make ct TEST_CHARTS=charts/csi-vault
- name: Test csi-vault chart
if: (matrix.k8s != 'v1.11.10') && (matrix.k8s != 'v1.12.10') && (matrix.k8s != 'v1.13.12')
run: |
export KUBECONFIG="${HOME}/.kube/config"
make ct TEST_CHARTS=charts/csi-vault
109 changes: 73 additions & 36 deletions .github/workflows/release.yml
Expand Up @@ -3,49 +3,86 @@ name: Release
on:
push:
tags:
- '*.*'
- "*.*"

jobs:

build:
name: Build
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v1

- name: Parse Parameters
id: params
run: |
GIT_TAG=${GITHUB_REF#'refs/tags/'}
echo ::set-output name=git_tag::$GIT_TAG
while IFS=$': \t' read -r marker v; do
case $marker in
Release)
echo ::set-output name=release::$v
;;
Release-tracker)
echo ::set-output name=release_tracker::$v
;;
esac
done < <(git tag -l --format='%(body)' $GIT_TAG)
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Install GitHub CLI
run: |
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
sudo mv bin/hub /usr/local/bin
- name: Clone charts repository
env:
GITHUB_TOKEN: ${{ secrets.LGTM_GITHUB_TOKEN }}
run: |
cd $HOME
git clone https://1gtm:${GITHUB_TOKEN}@github.com/appscode/charts.git
cd charts
git config user.name "1gtm"
git config user.email "1gtm@appscode.com"
- name: Clone charts repository
env:
GITHUB_TOKEN: ${{ secrets.LGTM_GITHUB_TOKEN }}
run: |
cd $HOME
git clone https://1gtm:${GITHUB_TOKEN}@github.com/appscode/charts.git
cd charts
git config user.name "1gtm"
git config user.email "1gtm@appscode.com"
- name: Package
run: |
echo "install helm 3"
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
echo "package charts"
for chart in vault-operator vault-catalog csi-vault
do
helm package charts/${chart}
mv ${chart}-*.tgz $HOME/charts/stable/${chart}
done
- name: Package
run: |
echo "install helm 3"
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
echo "package charts"
find charts -maxdepth 1 -mindepth 1 -type d -exec helm package {} -d {} \;
helm repo index --merge $HOME/charts/stable/index.yaml --url https://charts.appscode.com/stable/ charts
mv charts/index.yaml $HOME/charts/stable/index.yaml
cd charts
find . -maxdepth 1 -mindepth 1 -type d -exec mkdir -p $HOME/charts/stable/{} \;
find . -path ./charts -prune -o -name '*.tgz' -exec mv {} $HOME/charts/stable/{} \;
- name: Create pull request
env:
GITHUB_TOKEN: ${{ secrets.LGTM_GITHUB_TOKEN }}
run: |
export PR_BRANCH=${GITHUB_REPOSITORY}/${GITHUB_RUN_ID}
echo $PR_BRANCH
cd $HOME/charts
git checkout -b $PR_BRANCH
git add --all
git commit -a -s -m "Push KubeVault charts for $GITHUB_REF"
git push origin $PR_BRANCH -f
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
bin/hub pull-request -m "Push KubeVault charts for $GITHUB_REF"
- name: Create pull request
env:
GITHUB_TOKEN: ${{ secrets.LGTM_GITHUB_TOKEN }}
run: |
pr_branch=${GITHUB_REPOSITORY}/${GITHUB_RUN_ID}
cd $HOME/charts
git checkout -b $pr_branch
git add --all
ct_cmd="git commit -a -s -m \"Publish $GITHUB_REPOSITORY@${{ steps.params.outputs.git_tag }} charts\""
pr_cmd=$(cat <<EOF
hub pull-request \
--labels automerge \
--message "Publish $GITHUB_REPOSITORY@${{ steps.params.outputs.git_tag }} charts"
EOF
)
if [ ! -z ${{ steps.params.outputs.release }} ]; then
ct_cmd="$ct_cmd --message \"Release: ${{ steps.params.outputs.release }}\""
pr_cmd="$pr_cmd --message \"Release: ${{ steps.params.outputs.release }}\""
fi
if [ ! -z ${{ steps.params.outputs.release_tracker }} ]; then
ct_cmd="$ct_cmd --message \"Release-tracker: ${{ steps.params.outputs.release_tracker }}\""
pr_cmd="$pr_cmd --message \"Release-tracker: ${{ steps.params.outputs.release_tracker }}\""
fi
pr_cmd="$pr_cmd --message \"Signed-off-by: $(git config --get user.name) <$(git config --get user.email)>\""
eval "$ct_cmd"
git push -u origin HEAD -f
eval "$pr_cmd"

0 comments on commit aa62d4a

Please sign in to comment.