Skip to content

Commit 69b0545

Browse files
authored
Merge pull request #11 from lalyos/github-action
github action to release and automagically update version and sha
2 parents b8ea14a + 9c20254 commit 69b0545

File tree

3 files changed

+72
-2
lines changed

3 files changed

+72
-2
lines changed

.github/workflows/release.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
on:
3+
push:
4+
tags:
5+
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
6+
7+
name: Upload Release Asset
8+
9+
jobs:
10+
build:
11+
name: Upload Release Asset
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout master
15+
uses: actions/checkout@v2
16+
with:
17+
ref: master
18+
- name: Checkout code
19+
uses: actions/checkout@v2
20+
- name: Build project
21+
run: |
22+
make ci
23+
- name: Create Release
24+
id: create_release
25+
uses: actions/create-release@v1
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
with:
29+
tag_name: ${{ github.ref }}
30+
release_name: Release ${{ github.ref }}
31+
draft: false
32+
prerelease: false
33+
- name: Upload Release Asset
34+
id: upload-release-asset
35+
uses: actions/upload-release-asset@v1
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
with:
39+
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
40+
asset_path: ./examples.tar.gz
41+
asset_name: examples.tar.gz
42+
asset_content_type: application/tar+gzip
43+
- name: Commit updated krew yaml
44+
id: git_commit
45+
run: |
46+
git config --global user.email "[email protected]"
47+
git config --global user.name "Github Action"
48+
git stash -- plugins/examples.yaml
49+
git checkout master
50+
git stash pop
51+
git add plugins/examples.yaml
52+
git commit -m "update version references to: ${{ github.ref }}"
53+
git push origin master

Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@ tgz:
44
@tar -uf examples.tar kubectl-examples
55
gzip examples.tar
66

7+
ver = $(shell git describe --tags)
78
sha = $(shell shasum -a 256 < examples.tar.gz|cut -d" " -f1)
89

9-
update:
10+
fix-sha:
1011
@sed -i 's/sha256: .*$$/sha256: $(sha)/' plugins/examples.yaml
1112

12-
install: clean tgz update
13+
fix-version:
14+
@sed -i 's/v[0-9]\.[0-9]\.[0-9]/$(ver)/' plugins/examples.yaml
15+
16+
install: clean tgz fix-sha
1317
kubectl krew install --manifest=plugins/examples.yaml --archive=examples.tar.gz
1418

19+
ci: tgz fix-sha fix-version
20+
@echo github action ...
21+
1522
clean:
1623
@rm -f examples.tar.gz
1724
@kubectl krew uninstall examples || :

plugins/examples.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ spec:
1111
A reference repository of YAML with canonical
1212
and as-simple-as-possible demonstrations of
1313
kubernetes functionality and features.
14+
15+
Usage:
16+
interactively selecting resource type:
17+
kubectl examples
18+
19+
interactively selecting yaml:
20+
kubectl examples Service
21+
22+
create a sample ingress while modifying it:
23+
kubectl examples Ingress fanout | kubectl create -f - --edit
1424
platforms:
1525
- selector:
1626
matchExpressions:

0 commit comments

Comments
 (0)