-
-
Notifications
You must be signed in to change notification settings - Fork 840
106 lines (93 loc) · 3.66 KB
/
release-build.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
# This workflow creates a new tag, builds the release archives and uploads them to GitHub and our server
# It is triggered by pushing to the stable branch, either manually or by merging a PR created by the
# release-preparation workflow
name: "Release: Tag, Build & Deploy"
on:
push:
branches:
- stable
jobs:
tag:
name: Tag Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Prepare Environment
run: |
php .github/release.php current >> $GITHUB_ENV
- name: Check if a tag already exists
run: |
if git rev-parse "release-${{ env.current_version }}" >/dev/null 2>&1; then
echo "::error::Tag already exists, be sure to update the VERSION file for a hotfix"
exit 1
fi
- name: Create tag
uses: actions/github-script@v6
with:
# a privileged token is needed here to create the (protected) tag
github-token: ${{ secrets.RELEASE_TOKEN }}
script: |
const {current_version} = process.env;
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/release-${current_version}`,
sha: context.sha
});
build:
name: Build Release
needs: tag
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Prepare Environment
run: |
php .github/release.php current >> $GITHUB_ENV
- name: Build Archives
run: |
for F in $(awk '/export-ignore/{print $1}' .gitattributes); do
rm -rf $F
done
mkdir -p data/pages/playground
echo "====== PlayGround ======" > data/pages/playground/playground.txt
cd ..
mv ${{ github.event.repository.name }} "dokuwiki-${{ env.current_file }}"
tar -czvf "dokuwiki-${{ env.current_file }}.tgz" dokuwiki-${{ env.current_file }}
zip -r "dokuwiki-${{ env.current_file }}.zip" dokuwiki-${{ env.current_file }}
rm -rf "dokuwiki-${{ env.current_file }}"
mkdir ${{ github.event.repository.name }}
mv "dokuwiki-${{ env.current_version }}.tgz" ${{ github.event.repository.name }}/
mv "dokuwiki-${{ env.current_version }}.zip" ${{ github.event.repository.name }}/
- name: Release to Github
id: release
uses: softprops/action-gh-release@v1
with:
name: DokuWiki ${{ env.current_raw }} [${{ env.current_update }}]
tag_name: release-${{ env.current_version }}
files: |
dokuwiki-${{ env.current_file }}.tgz
dokuwiki-${{ env.current_file }}.zip
outputs:
version: ${{ env.current_version }}
file: ${{ env.current_file }}
url: ${{ fromJSON(steps.release.outputs.assets)[0].browser_download_url }}
deploy:
name: Deploy Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Download
run: |
wget ${{ needs.build.outputs.url }} -O dokuwiki-${{ needs.build.outputs.file }}.tgz
- name: Setup SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
# generate with ssh-keyscan -H <server>
known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
- name: Deploy to Server
run: |
scp "dokuwiki-${{ needs.build.outputs.file }}.tgz" ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:htdocs/src/dokuwiki/
ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd htdocs/src/dokuwiki/ && tar -xzvf dokuwiki-${{ needs.build.outputs.file }}.tgz"