Skip to content

Commit

Permalink
build!: Automatically add manifests to v* tags (#5880)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec authored May 12, 2021
1 parent be207a9 commit 3fff791
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 81 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/ci-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ jobs:
e2e-tests:
name: E2E Tests
runs-on: ubuntu-20.04
# test-api: 7m (1m10s locally)
# test-cli: 12m (4m locally)
# test-cron: 8m
# test-executor 8m (2m locally)
# test-functional: 13m (7m locally)
timeout-minutes: 20
env:
KUBECONFIG: /home/runner/.kubeconfig
Expand Down Expand Up @@ -97,7 +92,6 @@ jobs:
with:
path: dist/kustomize
key: kustomize
- run: git fetch --tags
- run: mkdir -p /tmp/log/argo-e2e
- name: Install and start K3S
timeout-minutes: 3
Expand Down Expand Up @@ -171,7 +165,6 @@ jobs:
sudo find /usr/local/include -type f | xargs sudo chmod a+r
sudo find /usr/local/include -type d | xargs sudo chmod a+rx
ls /usr/local/include/google/protobuf/
- run: git fetch --tags
- name: Create links
run: |
mkdir -p /home/runner/go/src/github.com/argoproj
Expand Down
59 changes: 26 additions & 33 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
- v*
branches:
- master
- dev-*

defaults:
run:
Expand All @@ -18,8 +17,8 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
platform: [linux/amd64]
target: [workflow-controller, argocli, argoexec]
platform: [ linux/amd64 ]
target: [ workflow-controller, argocli, argoexec ]
steps:
- uses: actions/checkout@v2

Expand Down Expand Up @@ -83,8 +82,8 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
platform: [linux/arm64]
target: [workflow-controller, argocli, argoexec]
platform: [ linux/arm64 ]
target: [ workflow-controller, argocli, argoexec ]
steps:
- uses: actions/checkout@v2

Expand Down Expand Up @@ -190,7 +189,7 @@ jobs:
push-linux-amd64-images:
name: Push manifest with linux/amd64
runs-on: ubuntu-20.04
needs: [build-linux-amd64]
needs: [ build-linux-amd64 ]
steps:
- uses: actions/checkout@v2
- name: Docker Login
Expand Down Expand Up @@ -233,7 +232,7 @@ jobs:
push-images:
name: Push manifest with all images
runs-on: ubuntu-20.04
needs: [build-linux-arm64, build-windows, push-linux-amd64-images]
needs: [ build-linux-arm64, build-windows, push-linux-amd64-images ]
steps:
- uses: actions/checkout@v2
- name: Docker Login
Expand Down Expand Up @@ -280,11 +279,11 @@ jobs:
test-images-linux-amd64:
name: Try pulling linux/amd64
runs-on: ubuntu-20.04
needs: [push-images]
needs: [ push-images ]
strategy:
matrix:
platform: [linux/amd64]
target: [workflow-controller, argocli, argoexec]
platform: [ linux/amd64 ]
target: [ workflow-controller, argocli, argoexec ]
steps:
- name: Docker Login
uses: Azure/docker-login@v1
Expand Down Expand Up @@ -317,7 +316,7 @@ jobs:
test-images-windows:
name: Try pulling windows
runs-on: windows-2019
needs: [push-images]
needs: [ push-images ]
steps:
- name: Docker Login
uses: Azure/docker-login@v1
Expand Down Expand Up @@ -348,14 +347,12 @@ jobs:
docker pull quay.io/$image_name
done
clis:
name: Build & publish CLIs
publish-release:
runs-on: ubuntu-20.04
if: startsWith(github.ref, 'refs/tags/v')
needs: [ push-images, test-images-linux-amd64, test-images-windows ]
steps:
- uses: actions/checkout@v2
with:
# 0 indicates all history for all branches and tags.
fetch-depth: 0
- uses: actions/setup-node@v1
with:
node-version: "14"
Expand All @@ -375,33 +372,29 @@ jobs:
path: /home/runner/go/pkg/mod
key: GOMODCACHE-v2-${{ hashFiles('**/go.mod') }}
# https://stackoverflow.com/questions/58033366/how-to-get-current-branch-within-github-actions
- name: Get tag
- run: make changelog VERSION=${GITHUB_REF##*/}
- run: cat changelog
- run: make manifests VERSION=${GITHUB_REF##*/}
- name: Print image tag (please check it is not `:latest`)
run: |
tag=$(basename $GITHUB_REF)
if [ $tag = "master" ]; then
tag="latest"
fi
echo "##[set-output name=tag;]$tag"
id: tag
- run: make changelog
grep image: dist/manifests/install.yaml
- run: go mod download
- run: make clis STATIC_FILES=true
- run: make clis STATIC_FILES=true VERSION=${GITHUB_REF##*/}
- name: Print version (please check it is not dirty)
run: dist/argo-linux-amd64 version
- run: make checksums
# https://github.com/softprops/action-gh-release
# This will draft the release and upload assets.
# This will publish the release and upload assets.
# If a conflict occurs (because you are not on a tag), the release will not be updated. This is a short coming
# of this action.
# Instead, delete the release so it is re-created.
- name: Draft release
uses: softprops/action-gh-release@v1
- uses: softprops/action-gh-release@v1
with:
draft: true
prerelease: true
tag_name: ${{ steps.tag.outputs.tag }}
body_path: dist/changelog.md
prerelease: ${{ startsWith(github.ref, 'refs/tags/v0') || contains(github.ref, 'rc') }}
body_path: changelog
files: |
dist/argo-*.gz
dist/argo-*.gz.sha256
manifests/*.yaml
dist/manifests/*.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ cmd/**/debug
hack/**/debug
/argo
/argoexec
changelog
debug.test
git-ask-pass.sh
*.iml
Expand Down
63 changes: 23 additions & 40 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ endif
ARGOEXEC_PKGS := $(shell echo cmd/argoexec && go list -f '{{ join .Deps "\n" }}' ./cmd/argoexec/ | grep 'argoproj/argo-workflows/v3/' | cut -c 39-)
CLI_PKGS := $(shell echo cmd/argo && go list -f '{{ join .Deps "\n" }}' ./cmd/argo/ | grep 'argoproj/argo-workflows/v3/' | cut -c 39-)
CONTROLLER_PKGS := $(shell echo cmd/workflow-controller && go list -f '{{ join .Deps "\n" }}' ./cmd/workflow-controller/ | grep 'argoproj/argo-workflows/v3/' | cut -c 39-)
MANIFESTS := $(shell find manifests -mindepth 2 -type f)
E2E_MANIFESTS := $(shell find test/e2e/manifests -mindepth 2 -type f)
E2E_EXECUTOR ?= pns
TYPES := $(shell find pkg/apis/workflow/v1alpha1 -type f -name '*.go' -not -name openapi_generated.go -not -name '*generated*' -not -name '*test.go')
CRDS := $(shell find manifests/base/crds -type f -name 'argoproj.io_*.yaml')
Expand Down Expand Up @@ -255,7 +253,7 @@ swagger: \
pkg/apiclient/workflowarchive/workflow-archive.swagger.json \
pkg/apiclient/workflowtemplate/workflow-template.swagger.json \
manifests/base/crds/full/argoproj.io_workflows.yaml \
manifests/install.yaml \
manifests \
api/openapi-spec/swagger.json \
api/jsonschema/schema.json

Expand Down Expand Up @@ -357,15 +355,27 @@ dist/kustomize:
cd dist && ./install_kustomize.sh 3.8.8
dist/kustomize version

# generates several installation files
manifests/install.yaml: $(MANIFESTS) dist/kustomize
./hack/update-image-tags.sh manifests/base $(VERSION)
manifests: dist/manifests/install.yaml \
dist/manifests/namespace-install.yaml \
dist/manifests/quick-start-minimal.yaml \
dist/manifests/quick-start-mysql.yaml \
dist/manifests/quick-start-postgres.yaml

manifests/install.yaml: /dev/null
dist/kustomize build --load_restrictor=none manifests/cluster-install | ./hack/auto-gen-msg.sh > manifests/install.yaml
manifests/namespace-install.yaml: /dev/null
dist/kustomize build --load_restrictor=none manifests/namespace-install | ./hack/auto-gen-msg.sh > manifests/namespace-install.yaml
manifests/quick-start-minimal.yaml: /dev/null
dist/kustomize build --load_restrictor=none manifests/quick-start/minimal | ./hack/auto-gen-msg.sh > manifests/quick-start-minimal.yaml
manifests/quick-start-mysql.yaml: /dev/null
dist/kustomize build --load_restrictor=none manifests/quick-start/mysql | ./hack/auto-gen-msg.sh > manifests/quick-start-mysql.yaml
manifests/quick-start-postgres.yaml: /dev/null
dist/kustomize build --load_restrictor=none manifests/quick-start/postgres | ./hack/auto-gen-msg.sh > manifests/quick-start-postgres.yaml

dist/manifests/%: manifests/$*
@mkdir -p dist/manifests
sed 's/:latest/:$(VERSION)/' manifests/$* > $@

# lint/test/etc

$(GOPATH)/bin/golangci-lint:
Expand All @@ -389,8 +399,8 @@ test: server/static/files.go dist/argosay
install: dist/kustomize
kubectl get ns $(KUBE_NAMESPACE) || kubectl create ns $(KUBE_NAMESPACE)
kubectl config set-context --current --namespace=$(KUBE_NAMESPACE)
@echo "installing PROFILE=$(PROFILE) VERSION=$(VERSION), E2E_EXECUTOR=$(E2E_EXECUTOR)"
dist/kustomize build --load_restrictor=none test/e2e/manifests/$(PROFILE) | sed 's/argoproj\//$(IMAGE_NAMESPACE)\//' | sed 's/:latest/:$(VERSION)/' | sed 's/containerRuntimeExecutor: docker/containerRuntimeExecutor: $(E2E_EXECUTOR)/' | kubectl -n $(KUBE_NAMESPACE) apply --prune -l app.kubernetes.io/part-of=argo -f -
@echo "installing PROFILE=$(PROFILE), E2E_EXECUTOR=$(E2E_EXECUTOR)"
dist/kustomize build --load_restrictor=none test/e2e/manifests/$(PROFILE) | sed 's/argoproj\//$(IMAGE_NAMESPACE)\//' | sed 's/containerRuntimeExecutor: docker/containerRuntimeExecutor: $(E2E_EXECUTOR)/' | kubectl -n $(KUBE_NAMESPACE) apply --prune -l app.kubernetes.io/part-of=argo -f -
ifeq ($(PROFILE),stress)
kubectl -n $(KUBE_NAMESPACE) apply -f test/stress/massive-workflow.yaml
kubectl -n $(KUBE_NAMESPACE) rollout restart deploy workflow-controller
Expand Down Expand Up @@ -543,7 +553,7 @@ dist/mixed.swagger.json: $(GOPATH)/bin/swagger $(SWAGGER_FILES) dist/swagger-con
swagger mixin -c $(shell cat dist/swagger-conflicts) $(SWAGGER_FILES) -o dist/mixed.swagger.json

dist/swaggifed.swagger.json: dist/mixed.swagger.json hack/swaggify.sh
cat dist/mixed.swagger.json | sed 's/VERSION/$(VERSION)/' | ./hack/swaggify.sh > dist/swaggifed.swagger.json
cat dist/mixed.swagger.json | ./hack/swaggify.sh > dist/swaggifed.swagger.json

dist/kubeified.swagger.json: dist/swaggifed.swagger.json dist/kubernetes.swagger.json
go run ./hack/swagger kubeifyswagger dist/swaggifed.swagger.json dist/kubeified.swagger.json
Expand Down Expand Up @@ -577,41 +587,14 @@ validate-examples: api/jsonschema/schema.json
.PHONY: pre-commit
pre-commit: codegen lint test start

changelog:
@mkdir -p dist
ifeq ($(GIT_BRANCH),master)
# on master, we just show the last 10 commits
git log --oneline -n10 > dist/changes
git log --oneline -n10 --format=%an | sort -u > dist/contributors
LOG_OPTS := '-n10'
else
# on a branch we show all commits since master
git log --oneline origin/master.. > dist/changes
git log --format=%an origin/master.. | sort -u > dist/contributors
endif
echo '## Changes' > dist/changelog.md
cat dist/changes >> dist/changelog.md
echo '## Contributors' >> dist/changelog.md
cat dist/contributors >> dist/changelog.md

# release - targets only available on release branch
ifneq ($(findstring release,$(GIT_BRANCH)),)

.PHONY: prepare-release
prepare-release: check-version-warning clean codegen manifests
# Commit if any changes
git diff --quiet || git commit -am "Update manifests to $(VERSION)"
# use "annotated" tag, rather than "lightweight", so in future we can distingush from "stable"
git tag -a $(VERSION) -m $(VERSION)

.PHONY: publish-release
publish-release:
git push
git push $(GIT_REMOTE) $(VERSION)
LOG_OPTS := 'origin/master..'
endif

.PHONY: check-version-warning
check-version-warning:
@if [[ "$(VERSION)" =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then echo -n "It looks like you're trying to use a SemVer version, but have not prepended it with a "v" (such as "v$(VERSION)"). The "v" is required for our releases. Do you wish to continue anyway? [y/N]" && read ans && [ $${ans:-N} = y ]; fi
changelog: /dev/null
version=$(VERSION) breaking_changes=`git log --oneline --grep '!:' $(LOG_OPTS)` changes=`git log --format=' * %h %s' $(LOG_OPTS)` contributors=`git log --format=' * %an' $(LOG_OPTS) | sort -u` envsubst < hack/changelog.md > changelog

.PHONY: parse-examples
parse-examples:
Expand Down
2 changes: 1 addition & 1 deletion api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"info": {
"description": "You can get examples of requests and responses by using the CLI with `--gloglevel=9`, e.g. `argo list --gloglevel=9`",
"title": "Argo Server API",
"version": "latest"
"version": "VERSION"
},
"paths": {
"/api/v1/archived-workflows": {
Expand Down
71 changes: 71 additions & 0 deletions hack/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Quick Start

## What's New?

Find out on [our blog](https://blog.argoproj.io).

## Breaking Changes

If any.

${breaking_changes}

## Argo CLI

### Mac

Available via `curl`

```sh
# Download the binary
curl -sLO https://github.com/argoproj/argo/releases/download/${version}/argo-darwin-amd64.gz

# Unzip
gunzip argo-darwin-amd64.gz

# Make binary executable
chmod +x argo-darwin-amd64

# Move binary to path
mv ./argo-darwin-amd64 /usr/local/bin/argo

# Test installation
argo version
```

### Linux

Available via `curl`

```sh
# Download the binary
curl -sLO https://github.com/argoproj/argo/releases/download/${version}/argo-linux-amd64.gz

# Unzip
gunzip argo-linux-amd64.gz

# Make binary executable
chmod +x argo-linux-amd64

# Move binary to path
mv ./argo-linux-amd64 /usr/local/bin/argo

# Test installation
argo version
```

## Install

```sh
kubectl create namespace argo
kubectl apply -n argo -f https://github.com/argoproj/argo-workflows/releases/download/${version}/install.yaml
```

## Changes

${changes}

## Contributors

${contributors}

0 comments on commit 3fff791

Please sign in to comment.