-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (97 loc) · 3.21 KB
/
Copy pathrelease.yml
File metadata and controls
120 lines (97 loc) · 3.21 KB
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
name: "Release"
permissions:
contents: write
concurrency:
group: release-${{ github.ref_name }}
cancel-in-progress: true
on:
workflow_dispatch:
inputs:
branch:
description: "Branch from which we make a release"
default: "main"
required: false
env:
GO_VERSION: "1.19"
RELEASE_COMMAND: "git add -f target"
PUSH_BRANCH: ${{ github.repository.default_branch }}
jobs:
prepare:
name: "🔧 Prepare"
runs-on: ubuntu-latest
steps:
- name: 🛎️ Checkout ${{ env.PUSH_BRANCH }}
uses: actions/checkout@v4
with:
ref: ${{ env.PUSH_BRANCH }}
fetch-depth: 1
- uses: ./.github/actions/init-go
with:
go-version: ${{ env.GO_VERSION }}
- uses: ./.github/actions/generate-build-env
- uses: ./.github/actions/tidy-all-and-generate
- name: 📦 Save the repository as an artifact
uses: actions/upload-artifact@v4
with:
name: src-gen
path: .
release:
name: "🚀 Publication of release"
needs: [ prepare ]
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: 🛎️ Checkout ${{ env.PUSH_BRANCH }}
uses: actions/checkout@v4
with:
ref: ${{ env.PUSH_BRANCH }}
fetch-depth: 1
- name: 📥 Download src-gen
uses: actions/download-artifact@v4
with:
name: src-gen
path: .
- name: 🗒️ Source env
shell: bash
run: cat build_env.txt >> $GITHUB_ENV
- uses: ./.github/actions/github-setup-user
- name: 🏷️ Create Commit without “heavy” and tag ${BUILD_VER}
id: tag
shell: bash
env:
GOFLAGS: -mod=mod
run: |
set -Eeuo pipefail
ORIG_SHA=$(git rev-parse HEAD)
${{ env.RELEASE_COMMAND }}
git rm -f -r --cached --ignore-unmatch .github .idea _generate _run cli gen.go .gitignore
git rm -f --cached --ignore-unmatch $(git ls-files '*.bin' '*.md' '*_test.go')
git commit -m "release(${BUILD_VER}): strip heavy assets"
git tag -a "${BUILD_VER}" -m "Release ${BUILD_VER}"
git push origin "${BUILD_VER}"
git reset --hard "$ORIG_SHA"
- name: 🚀 Create a release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.BUILD_VER }}
name: ${{ env.BUILD_VER }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: ✔️ Finish
run: |
new_version=$(go run github.com/amazing-generators/gometagen/cmd/gometagen@latest version minor -source ./_run/values.yml)
git add ./_run/values.yml
git commit -m "actions [$new_version] "$'\n'"Build: [${BUILD_VER}] >> [$new_version]"
git push origin HEAD:main
echo "🎉 Release $BUILD_VER successfully published!"
- name: 🧹 Remove temporary artifacts
if: success()
uses: geekyeggo/delete-artifact@v5
with:
name: |
build-env
src-gen
${{ env.BUILD_NAME }}.*
failOnError: false