-
Notifications
You must be signed in to change notification settings - Fork 108
156 lines (128 loc) · 5.2 KB
/
deploy.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
149
150
151
152
153
154
155
156
name: Deploy
on:
push:
tags:
- "*.*"
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
steps:
- name: Checkout the repository
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get install -y libimage-exiftool-perl
python -m pip install --upgrade pip
pip install pytest
pip install -r requirements-dev.txt
- name: Run tests
run: pytest
deploy-snap:
needs: test
runs-on: ubuntu-18.04
strategy:
matrix:
architecture: [ linux/amd64, linux/386, linux/arm/v7, linux/ppc64le ]
steps:
- name: Checkout the repository
uses: actions/[email protected]
with:
fetch-depth: 0
- id: snapcraft
name: Build Snap
run: |
LATEST_VERSION=`git tag | sort -t. -k 1.2,1n -k 2,2n -k 3,3n -k 4,4n | tail -1`
CURRENT_VERSION=`echo -e "import urllib.request, json\n\nrequest = urllib.request.Request('http://api.snapcraft.io/v2/snaps/info/phockup')\nrequest.add_header('Snap-Device-Series', '16')\narchitectures = {'amd64': 'linux/amd64', 'i386': 'linux/386', 'arm64': 'linux/arm64', 'armhf': 'linux/arm/v7', 'ppc64el': 'linux/ppc64le', 's390x': 'linux/s390x'}\nwith urllib.request.urlopen(request) as url:\n data = json.loads(url.read().decode())\n for c in data['channel-map']:\n channel = c['channel']\n if architectures.get(channel['architecture']) == '${{ matrix.architecture }}' and channel['name'] == 'stable':\n print(c['version'])" | python3`
if [ "$LATEST_VERSION" = "$CURRENT_VERSION" ]; then
echo ::set-output name=deploy::0
exit
fi
echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json > /dev/null
sudo systemctl restart docker
docker run --rm --tty \
--security-opt apparmor:unconfined \
--cap-add SYS_ADMIN \
multiarch/qemu-user-static --reset -p yes
docker run --rm --tty \
--security-opt apparmor:unconfined \
--cap-add SYS_ADMIN \
--device /dev/fuse \
--volume /sys \
--volume /sys/fs/cgroup:/sys/fs/cgroup:ro \
--volume $GITHUB_WORKSPACE:$GITHUB_WORKSPACE \
--workdir $GITHUB_WORKSPACE \
--platform "${{ matrix.architecture }}" \
--env PLAYTEST="${{ matrix.playtest }}" \
diddledan/snapcraft:core18
SNAP=`find $GITHUB_WORKSPACE -maxdepth 1 -type f -name '*.snap' | head -n1`
echo ::set-output name=snap::"$SNAP"
echo ::set-output name=deploy::1
- name: Deploy to Snap Store
uses: snapcore/action-publish@v1
if: ${{ steps.snapcraft.outputs.deploy == 1 }}
with:
store_login: ${{ secrets.SNAPCRAFT_LOGIN }}
snap: ${{ steps.snapcraft.outputs.snap }}
release: stable
deploy-brew:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout the main repository
uses: actions/[email protected]
with:
fetch-depth: 0
path: phockup
- name: Checkout the Homebrew repository
uses: actions/[email protected]
with:
repository: ivandokov/homebrew-contrib
path: homebrew-contrib
ssh-key: ${{ secrets.HOMEBREW_PUSH_KEY }}
- name: Deploy to Homebrew
run: |
cd phockup
LATEST_VERSION=`git tag | sort -t. -k 1.2,1n -k 2,2n -k 3,3n -k 4,4n | tail -1`
CURRENT_VERSION=`cat ../homebrew-contrib/Formula/phockup.rb | tr '\n' '\r' | sed 's/.*archive\/\([0-9.]*\)\.tar.*/\1/g'`
if [ "$LATEST_VERSION" = "$CURRENT_VERSION" ]; then
exit
fi
curl -sLo $LATEST_VERSION.tar.gz https://github.com/ivandokov/phockup/archive/$LATEST_VERSION.tar.gz
SHASUM=`shasum -a 256 $LATEST_VERSION.tar.gz | awk '{print $1}'`
rm $LATEST_VERSION.tar.gz
cd ../homebrew-contrib
sed -i "s/archive\/[0-9.]*\.tar/archive\/$LATEST_VERSION\.tar/" Formula/phockup.rb
sed -i "0,/sha256/{s/sha256 .*/sha256 \"$SHASUM\"/}" Formula/phockup.rb
git config user.name github-actions
git config user.email [email protected]
git add .
git commit -m $LATEST_VERSION
git push
deploy-dockerhub:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Publish to Dockerhub
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: ivandokov/phockup
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
platforms: linux/amd64,linux/arm64