-
Notifications
You must be signed in to change notification settings - Fork 0
148 lines (136 loc) · 5.04 KB
/
release.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Publish a release
on:
workflow_dispatch:
inputs: {}
jobs:
gh_release:
runs-on: ubuntu-latest
outputs:
release_number: ${{ steps.determine_number.outputs.release_number }}
env:
GH_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up git
run: |
git config --global user.email "[email protected]"
git config --global user.name "Jan Buchar"
- name: Determine release number
id: determine_number
run: |
echo release_number=$(( 1 + $(gh release list --json tagName |
jq --raw-output '.[] | .tagName' |
cut -d '-' -f 2 |
sort -n -r |
head -n 1) )) >> "$GITHUB_OUTPUT"
- name: Create branch
run: |
git switch -c ${{ env.PR_BRANCH }}
- name: Update changelog and generate release notes
run: |
git-cliff --tag "release-${{ steps.determine_number.outputs.release_number }}" --unreleased --strip all > release_notes.md
git-cliff --tag "release-${{ steps.determine_number.outputs.release_number }}" > CHANGELOG.md
- name: Push branch and create PR
run: |
git commit -am "Release ${{ steps.determine_number.outputs.release_number }}"
git push --set-upstream origin ${{ env.PR_BRANCH }}
gh pr create \
--base master \
--head ${{ env.PR_BRANCH }} \
--title "chore: Release ${{ steps.determine_number.outputs.release_number }} [skip-ci]" \
--body "Automated pull request - prepare release ${{ steps.determine_number.outputs.release_number }}"
- name: Merge PR
id: merge_pr
run: |
gh pr merge --squash --auto --delete-branch ${{ env.PR_BRANCH }}
echo sha=$( gh pr view --json mergeCommit ${{ env.PR_BRANCH }} | jq --raw-output .mergeCommit.oid ) >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: "release-${{ steps.determine_number.outputs.release_number }}"
name: "Release ${{ steps.determine_number.outputs.release_number }}"
target_commitish: ${{ steps.merge_pr.outputs.sha }}
body_path: release_notes.md
prepare_pkgbuild:
runs-on: ubuntu-latest
needs: gh_release
env:
TARBALL_URL: https://github.com/janbuchar/rorqual/archive/refs/tags/release-${{ needs.gh_release.outputs.release_number }}.tar.gz
RELEASE_NUMBER: ${{ needs.gh_release.outputs.release_number }}
GH_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install Poetry
uses: abatilo/actions-poetry@v2
- name: Use cache
uses: actions/cache@v4
with:
path: out/
key: ${{ github.run_id }}
- name: Prepare output dir
run: mkdir -p out
- name: Create requirements.txt
run: |
poetry export -f requirements.txt --without-hashes --without dev -o out/requirements.txt
cat out/requirements.txt
- name: Copy launcher
run: cp aur/rorqual out/rorqual
- name: Create PKGBUILD
run: |
cat aur/PKGBUILD.template |
TARBALL_HASH=$(gh api $TARBALL_URL | sha256sum | cut -f 1 -d " ") \
REQUIREMENTS_HASH=$(sha256sum out/requirements.txt | cut -f 1 -d " ") \
LAUNCHER_HASH=$(sha256sum out/rorqual | cut -f 1 -d " ") \
envsubst '${TARBALL_URL} ${RELEASE_NUMBER} ${TARBALL_HASH} ${REQUIREMENTS_HASH} ${LAUNCHER_HASH}' > out/PKGBUILD
cat out/PKGBUILD
aur_push:
runs-on: ubuntu-latest
needs: prepare_pkgbuild
steps:
- name: Use cache
uses: actions/cache@v4
with:
path: out/
key: ${{ github.run_id }}
- name: Prepare output dir
run: mkdir -p out
- name: Setup AUR SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.AUR_PRIVATE_KEY }}
- name: Checkout AUR package
run: |
mkdir -p .ssh
ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts
git init
git remote add origin ssh://[email protected]/rorqual-venv.git
git pull origin master
- name: Apply changes
run: |
mv out/* ./
rm -rf out
- name: Prepare .SRCINFO
uses: heyhusen/[email protected]
with:
flags: ''
namcap: false
srcinfo: true
- name: Push to AUR
run: |
git config --global user.email "[email protected]"
git config --global user.name "Jan Buchar"
git add .
git commit -m "Release ${{ needs.gh_release.outputs.release_number }}"
git push origin master