-
Notifications
You must be signed in to change notification settings - Fork 8
142 lines (118 loc) · 4.47 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
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
workflow_dispatch:
name: Build Release
jobs:
deb-package:
name: build DEB-Package
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get artifact
run: ./get-pkg.sh
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: deb-package
path: package/*
github-release:
needs: deb-package
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
name: GitHub Release
runs-on: ubuntu-22.04
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: deb-package
- name: Extract current changes
run: cat *.changes | sed '0,/^Changes:$/d' | sed '/Checksums.*/Q' | sed '1,2d' | tail >> ./current-changes
- name: Define distribution variables
run: |
export DISTRIBUTION=$(grep -i ^Distribution *.changes | awk -F\: '{ print $2 }' | awk '{ print $1 }')
echo "DISTRIBUTION=$DISTRIBUTION" >> $GITHUB_ENV
export VERSION=$(grep -i ^Version *.changes | awk -F\: '{ print $2 }' | awk '{ print $1 }')
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Test if it's a testing prerelease
id: check_prerelease
uses: haya14busa/action-cond@v1
with:
cond: ${{ env.DISTRIBUTION == 'lmn72' }}
if_true: "true"
if_false: "false"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ env.VERSION }} (${{ env.DISTRIBUTION }})
draft: false
prerelease: ${{ steps.check_prerelease.outputs.value }}
body_path: ./current-changes
- name: Delete current changes file
run: rm ./current-changes
- name: Upload Release Assets
id: upload-release-assets
uses: dwenegar/upload-release-assets@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.create_release.outputs.id }}
assets_path: .
publish:
needs: deb-package
name: Push latest release to archive repo
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') && github.repository == 'linuxmuster/linuxmuster-linbo7'
runs-on: ubuntu-latest
steps:
- name: Setup SSH Key
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-add - <<< "${{ secrets.REPO_SSH_KEY }}"
- name: Clone archive repo
uses: actions/checkout@v3
with:
repository: "linuxmuster/deb"
ssh-key: ${{ secrets.REPO_SSH_KEY }}
path: "./deb"
- name: Prepare download
run: mkdir "package"
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: deb-package
path: "./package"
- name: Prepare environment
run: |
export PACKAGE=$(grep -i ^Source package/*.changes | awk -F\: '{ print $2 }' | awk '{ print $1 }')
echo "PACKAGE=$PACKAGE" >> $GITHUB_ENV
export DISTRIBUTION=$(grep -i ^Distribution package/*.changes | awk -F\: '{ print $2 }' | awk '{ print $1 }')
echo "DISTRIBUTION=$DISTRIBUTION" >> $GITHUB_ENV
export VERSION=$(grep -i ^Version package/*.changes | awk -F\: '{ print $2 }' | awk '{ print $1 }')
echo "VERSION=$VERSION" >> $GITHUB_ENV
export BRANCH_NAME=$(echo "$PACKAGE-$DISTRIBUTION-$VERSION" | sed 's/~/tilde/')
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
- name: Copy packages
run: |
mkdir -p deb/packages/$PACKAGE/$DISTRIBUTION
rm -rf deb/packages/$PACKAGE/$DISTRIBUTION/*
cp package/* deb/packages/$PACKAGE/$DISTRIBUTION
- name: Push to repo
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
cd deb
git config user.name github-actions
git config user.email [email protected]
git checkout -b update/$BRANCH_NAME
git add *
git commit -a -m "Update $PACKAGE/$DISTRIBUTION to $VERSION (By GitHub actions)"
git push --set-upstream origin update/$BRANCH_NAME