-
-
Notifications
You must be signed in to change notification settings - Fork 1
138 lines (120 loc) · 4.13 KB
/
Release.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: Publish Release
concurrency:
group: ci-${{ github.repository }}-release
cancel-in-progress: false
on:
push:
branches:
- "main"
paths-ignore:
- "docs/**"
- "CHANGELOG.md"
jobs:
create-release:
uses: fullstack-devops/git-workflows/.github/workflows/create-release.yml@main
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
quality-gate:
runs-on: ubuntu-latest
needs: [create-release]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Test
run: make test/cover
- name: Audit
run: make audit
- name: debugging git
run: |
echo "git name-rev HEAD: $(git name-rev HEAD)"
echo "git log -1 --pretty=format:"%s": $(git log -1 --pretty=format:"%s")"
echo "git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@': $(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')"
build:
runs-on: ubuntu-latest
needs: [create-release, quality-gate]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Build
run: make
env:
VERSION: "${{ needs.create-release.outputs.version }}"
- name: Setup UPX
uses: crazy-max/ghaction-upx@v3
with:
install-only: true
- name: Compress binaries with upx
run: make upx
env:
VERSION: "${{ needs.create-release.outputs.version }}"
- name: Cache build outputs
uses: actions/cache@v4
env:
cache-name: cache-outputs-modules
with:
path: build/package/
key: awesome-ci-${{ github.sha }}-${{ hashFiles('build/package/awesome-ci*') }}
restore-keys: |
awesome-ci-${{ github.sha }}
publish-release:
environment: production
runs-on: ubuntu-latest
needs: [create-release, build]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup awesome-ci
uses: fullstack-devops/awesome-ci-action@main
- name: get cached build outputs
uses: actions/cache@v4
env:
cache-name: cache-outputs-modules
with:
path: build/package/
key: awesome-ci-${{ github.sha }}
- name: list generated artifacts
working-directory: build/package
run: ls -la
- name: Publish Release
run: >-
awesome-ci release publish --release-id ${{ needs.create-release.outputs.releaseid }}
-a "file=build/package/awesome-ci_${{ needs.create-release.outputs.version }}_linux-amd64"
-a "file=build/package/awesome-ci_${{ needs.create-release.outputs.version }}_linux-arm64"
-a "file=build/package/awesome-ci_${{ needs.create-release.outputs.version }}_windows-amd64.exe"
-a "file=build/package/awesome-ci_${{ needs.create-release.outputs.version }}_windows-arm64.exe"
--body "build/package/release-template.md"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
update_action:
runs-on: ubuntu-latest
needs: [create-release, publish-release]
steps:
- name: Check out awesome-ci-action
uses: actions/checkout@v4
with:
repository: fullstack-devops/awesome-ci-action
token: ${{ secrets.ACI_REPO_TOKEN }}
persist-credentials: true
- name: Update version and push
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
sed -i "s/\([0-9]\+\.[0-9]\+\.[0-9]\+\)/$NEW_VERSION/g" action.yml README.md
git status
git commit -a -m "update to version v$NEW_VERSION"
git tag v$NEW_VERSION -m "update to version v$NEW_VERSION"
git push --follow-tags
env:
NEW_VERSION: ${{ needs.create-release.outputs.version }}