-
Notifications
You must be signed in to change notification settings - Fork 1
210 lines (193 loc) · 8.68 KB
/
Copy pathbuild-docker.yml
File metadata and controls
210 lines (193 loc) · 8.68 KB
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
name: Build remote / local with docker
on:
push:
workflow_dispatch:
pull_request:
# https://github.com/dorny/paths-filter?tab=readme-ov-file#example
# https://github.com/vtnerd/monero-lws/blob/master/.github/workflows/docker-build.yml
jobs:
dockerbuild:
runs-on: ubuntu-22.04
permissions:
contents: write
packages: write
discussions: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
ref: ${{ github.ref }}
- name: Check if we rebuild + push docker image
id: changes
uses: dorny/paths-filter@v3
with:
filters: |
src:
- 'Dockerfile'
- 'submodules/mktorrent/**'
- 'create_monero_torrent.sh'
transmission:
- '.github/workflows/docker/Dockerfile.transmission'
- name: ghcr login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: transmission-show (pull or build)
run: |
tag_name="ghcr.io/${GITHUB_REPOSITORY_OWNER}/monero-torrent-show:latest"
case "${{ steps.changes.outputs.transmission }}" in
true)
docker build -f ./.github/workflows/docker/Dockerfile.transmission -t $tag_name .
docker push -a ghcr.io/${GITHUB_REPOSITORY_OWNER}/monero-torrent-show
;;
*)
docker pull "$tag_name" || docker build -f ./.github/workflows/docker/Dockerfile.transmission -t "$tag_name" .
;;
esac
- name: get version from hashes.txt
id: hashes_version
run: |
HASHES_URL="https://www.getmonero.org/downloads/hashes.txt"
curl -sL $HASHES_URL -o hashes.txt
VERSION=$(awk '/monero-source-v/ {print $2}' "hashes.txt" | awk -F".tar.bz2" '{print $1}' | awk -F"-" '{print $3}')
VERSION_GUI=$(awk '/monero-gui-source-v/ {print $2}' "hashes.txt" | awk -F".tar.bz2" '{print $1}' | awk -F"-" '{print $4}')
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "VERSION_GUI=$VERSION_GUI" >> $GITHUB_ENV
env:
VERSION: $VERSION
VERSION_GUI: $VERSION_GUI
- name: check getmonero webseed + versioned hashes file
run: |
CDN_URL="https://downloads.getmonero.org"
if ! wget --spider "$CDN_URL/hashes-$VERSION"; then
echo "Webseed FAILED: hashes-$VERSION"
#exit 1
fi
if ! wget --spider "$CDN_URL/hashes-$VERSION_GUI"; then
echo "Webseed FAILED: hashes-$VERSION_GUI"
#exit 1
fi
for file in $(awk '/monero-/ {print $2}' "hashes.txt"); do
dir=cli
part="monero-$VERSION"
echo $file
if [[ $file =~ gui ]]; then
dir=gui
part="monero-gui-$VERSION_GUI"
fi
url=$CDN_URL/${part}/${dir}/${file}
if ! wget --spider "$url"; then
echo "Webseed FAILED: $url"
#exit 1
else
echo "Webseed OK: $url"
fi
done
# note: its possible gui + cli have different versions. combine them for the key.
- uses: actions/cache@v4
id: binaries_cache
with:
path: ./downloads
key: monero-binaries-${{ env.VERSION }}-gui-${{ env.VERSION_GUI }}
- if: ${{ steps.binaries_cache.outputs.cache-hit != 'true' }}
name: Run remote profile
run: |
if [ "${{ steps.changes.outputs.src }}" = "true" ] || [ "${{ github.ref_type }}" = "tag" ]; then
# force rebuild instead of pulling container.
docker compose --profile remote up --build
else
docker compose --profile remote up
fi
MAGNET_LINK=$(docker run --rm -v "./watch:/watch:ro" ghcr.io/plowsof/monero-torrent-show:latest -m /watch/monero-$VERSION.torrent)
MAGNET_LINK_GUI=$(docker run --rm -v "./watch:/watch:ro" ghcr.io/plowsof/monero-torrent-show:latest -m /watch/monero-gui-$VERSION_GUI.torrent)
echo "MAGNET_LINK_REMOTE=$MAGNET_LINK" >> $GITHUB_ENV
echo "MAGNET_LINK_REMOTE_GUI=$MAGNET_LINK_GUI" >> $GITHUB_ENV
sudo rm ./watch/*
- name: Move downloads to cdn
run: |
mkdir -p ./cdn
sudo mv ./downloads/* ./cdn/
- name: Run local profile
run: |
if [ "${{ steps.changes.outputs.src }}" = "true" ] || [ "${{ github.ref_type }}" = "tag" ]; then
docker compose --profile local up --build
else
docker compose --profile local up
fi
MAGNET_LINK=$(docker run --rm -v "./watch:/watch:ro" ghcr.io/plowsof/monero-torrent-show:latest -m /watch/monero-$VERSION.torrent)
MAGNET_LINK_GUI=$(docker run --rm -v "./watch:/watch:ro" ghcr.io/plowsof/monero-torrent-show:latest -m /watch/monero-gui-$VERSION_GUI.torrent)
echo "MAGNET_LINK_LOCAL=$MAGNET_LINK" >> $GITHUB_ENV
echo "MAGNET_LINK_LOCAL_GUI=$MAGNET_LINK_GUI" >> $GITHUB_ENV
INFOHASH="${MAGNET_LINK#*btih:}"
INFOHASH="${INFOHASH%%&*}"
INFOHASH_GUI="${MAGNET_LINK_GUI#*btih:}"
INFOHASH_GUI="${INFOHASH_GUI%%&*}"
TORRENT_URL="https://github.com/${GITHUB_REPOSITORY}/releases/download/${GITHUB_REF_NAME}/monero-${VERSION}.torrent"
TORRENT_URL_GUI="https://github.com/${GITHUB_REPOSITORY}/releases/download/${GITHUB_REF_NAME}/monero-gui-${VERSION_GUI}.torrent"
echo "INFOHASH=$INFOHASH" >> $GITHUB_ENV
echo "INFOHASH_GUI=$INFOHASH_GUI" >> $GITHUB_ENV
echo "TORRENT_URL=$TORRENT_URL" >> $GITHUB_ENV
echo "TORRENT_URL_GUI=$TORRENT_URL_GUI" >> $GITHUB_ENV
- name: Push new image to ghcr
if: github.ref_type == 'tag' || ( steps.changes.outputs.src == 'true' && github.ref == 'refs/heads/main' )
run: docker push -a ghcr.io/${GITHUB_REPOSITORY_OWNER}/monero-torrent-build-env
- if: ${{ steps.binaries_cache.outputs.cache-hit != 'true' }}
name: Compare hashes for local/remote build and write summary
run: |
if [ "$MAGNET_LINK_REMOTE" = "$MAGNET_LINK_LOCAL" ] && [ "$MAGNET_LINK_REMOTE_GUI" = "$MAGNET_LINK_LOCAL_GUI" ]; then
echo "- Magnet links match: " >> $GITHUB_STEP_SUMMARY
echo ">$MAGNET_LINK_LOCAL" >> $GITHUB_STEP_SUMMARY
echo ">$MAGNET_LINK_LOCAL_GUI" >> $GITHUB_STEP_SUMMARY
else
echo "- Magnet links differ" >> $GITHUB_STEP_SUMMARY
echo "Remote: $MAGNET_LINK_REMOTE" >> $GITHUB_STEP_SUMMARY
echo "Local: $MAGNET_LINK_LOCAL" >> $GITHUB_STEP_SUMMARY
echo "Remote GUI: $MAGNET_LINK_REMOTE_GUI" >> $GITHUB_STEP_SUMMARY
echo "Local GUI: $MAGNET_LINK_LOCAL_GUI" >> $GITHUB_STEP_SUMMARY
exit 1
fi
- name: create release notes
run: |
{
echo "### CLI Torrent info"
echo '```'
docker run --rm -v "./watch:/watch:ro" ghcr.io/plowsof/monero-torrent-show:latest /watch/monero-$VERSION.torrent
echo '```'
echo "### GUI Torrent info"
echo '```'
docker run --rm -v "./watch:/watch:ro" ghcr.io/plowsof/monero-torrent-show:latest /watch/monero-gui-$VERSION_GUI.torrent
echo '```'
echo "### 🧲 CLI Magnet Link"
echo '```'
docker run --rm -v "./watch:/watch:ro" ghcr.io/plowsof/monero-torrent-show:latest -m /watch/monero-$VERSION.torrent
echo '```'
echo "### 🧲 GUI Magnet Link"
echo '```'
docker run --rm -v "./watch:/watch:ro" ghcr.io/plowsof/monero-torrent-show:latest -m /watch/monero-gui-$VERSION_GUI.torrent
echo '```'
} >> release-notes.md
- name: Add release notes to step summary
run: |
cat release-notes.md >> $GITHUB_STEP_SUMMARY
- name: Release
uses: softprops/action-gh-release@v2
if: github.ref_type == 'tag'
with:
body_path: release-notes.md
files: watch/*
- name: Add to RSS feed
if: github.ref_type == 'tag'
run: |
git config --local user.email "torrent@users.noreply.github.com"
git config --local user.name "updateRSS"
git fetch origin "${GITHUB_REF_NAME}"
git checkout "${GITHUB_REF_NAME}"
git checkout -b update-rss-${VERSION}
./rss/add_to_rss.sh
git add ./rss/torrent-rss.xml
git commit -m "RSS: add $VERSION"
git push origin HEAD:update-rss-${VERSION}-gui-${VERSION_GUI} --force