-
Notifications
You must be signed in to change notification settings - Fork 1
129 lines (118 loc) · 4.49 KB
/
main.yml
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
name: Release Application
on:
push:
branches:
- master
jobs:
build:
name: publish tag
runs-on: ubuntu-latest
steps:
- shell: bash
run: |
echo "## Release Application" >> $GITHUB_STEP_SUMMARY
echo "### build and push tag for aklog" >> $GITHUB_STEP_SUMMARY
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-tags: 'true'
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: read cfg to env
id: read_cfg
uses: mikefarah/yq@master
with:
cmd: |
VERSION_PREFIX=$(yq '.version.prefix' cfg.yml)
echo "VERSION_PREFIX:${VERSION_PREFIX}"
v_major=$(yq '.version.major' cfg.yml)
echo "v_major:${v_major}"
v_minor=$(yq '.version.minor' cfg.yml)
echo "v_minor:${v_minor}"
VERSION_MAJOR_MINOR="${v_major}.${v_minor}"
echo "VERSION_MAJOR_MINOR:${VERSION_MAJOR_MINOR}"
echo "VERSION_PREFIX=$VERSION_PREFIX" >> $GITHUB_ENV
echo "VERSION_MAJOR_MINOR=$VERSION_MAJOR_MINOR" >> $GITHUB_ENV
- name: generate git tag
id: gennerate_tag
run: python .github/build_new_tag.py
- name: Push Git Tag
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git tag $NEW_TAG
git push origin $NEW_TAG
echo "- :white_check_mark: push tag done." >> $GITHUB_STEP_SUMMARY
- name: update formula config file
id: update_formula
run: |
echo "- :white_check_mark: update formula config file" >> $GITHUB_STEP_SUMMARY
url="https://github.com/wswenyue/aklog/archive/${NEW_TAG}.tar.gz"
sha256=$(wget -O aklog.tar.gz ${url} && shasum -a 256 aklog.tar.gz | cut -d ' ' -f 1)
echo "> version: ${NEW_VERSION}" >> $GITHUB_STEP_SUMMARY
echo "> new_tag: ${NEW_TAG}" >> $GITHUB_STEP_SUMMARY
echo "> url: ${url}" >> $GITHUB_STEP_SUMMARY
echo "> sha256: ${sha256}" >> $GITHUB_STEP_SUMMARY
rm -rf ./aklog.tar.gz
en_url=`echo $url |sed 's#\/#\\\/#g'`
sed -e "s/#_version_#/${NEW_VERSION}/g; s/#_url_#/${en_url}/g; s/#_sha256_#/${sha256}/g" .github/data/aklog.rb > formula.rb
echo "- :arrow_double_up: upload formula file ..." >> $GITHUB_STEP_SUMMARY
- name: upload new Formula
uses: actions/upload-artifact@v4
with:
name: formula
path: formula.rb
homebrew:
name: publish homebrew
needs: build
runs-on: ubuntu-latest
permissions:
pull-requests: write # 'write' access to pull requests
contents: write # We generate static HTML, JS, CSS so we need write access to the repo
pages: write
id-token: write
deployments: write
statuses: write
actions: write
checks: read
steps:
- shell: bash
run: |
echo "### publish homebrew aklog" >> $GITHUB_STEP_SUMMARY
- name: Checkout homebrew-aklog
uses: actions/checkout@v4
with:
repository: wswenyue/homebrew-aklog
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
persist-credentials: true
- name: Download formula
uses: actions/download-artifact@v4
with:
name: formula
- shell: bash
run: |
echo "- :white_check_mark: checkout done." >> $GITHUB_STEP_SUMMARY
echo "- :white_check_mark: download formula down." >> $GITHUB_STEP_SUMMARY
cat formula.rb > Formula/aklog.rb
rm -rf formula.rb
echo "- :white_check_mark: overwrite formula file." >> $GITHUB_STEP_SUMMARY
- name: Commit files
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
ls -alh
git status
git commit -a -m "rebot publish commit"
echo "- :white_check_mark: git add and commit." >> $GITHUB_STEP_SUMMARY
- name: Push changes
uses: ad-m/github-push-action@master
with:
repository: wswenyue/homebrew-aklog
ssh: true
branch: ${{ github.ref }}
- shell: bash
run: |
echo "- :white_check_mark: git push succeed." >> $GITHUB_STEP_SUMMARY
echo "### :smile: I'm so lucky to have done this. Congratulations!!! :smile:" >> $GITHUB_STEP_SUMMARY