Skip to content

Commit 1bcf893

Browse files
committed
update links
1 parent 3c42bd9 commit 1bcf893

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

.github/workflows/update-links.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Update Download Links
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
test_version:
9+
description: 'Version to test'
10+
required: true
11+
default: 'v1.0.0'
12+
13+
jobs:
14+
update-redirects:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Prepare Version Information
18+
id: prep_info
19+
run: |
20+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
21+
TAG="${{ github.event.inputs.test_version }}"
22+
else
23+
TAG="${{ github.event.release.tag_name }}"
24+
fi
25+
26+
echo "TAG_NAME=$TAG" >> $GITHUB_ENV
27+
CLEAN_VER=${TAG#v}
28+
echo "CLEAN_VERSION=$CLEAN_VER" >> $GITHUB_ENV
29+
30+
# ======================================================
31+
# 1. Update Setup Redirect Page
32+
# ======================================================
33+
- name: Checkout Setup Repository
34+
uses: actions/checkout@v3
35+
with:
36+
repository: AudioShelf/setup
37+
token: ${{ secrets.ORG_ADMIN_TOKEN }}
38+
path: setup-repo
39+
40+
- name: Update Setup Redirect
41+
run: |
42+
cd setup-repo
43+
NEW_LINK="https://github.com/M-Rajabi-Dev/AudioShelf/releases/download/${{ env.TAG_NAME }}/AudioShelf-${{ env.CLEAN_VERSION }}-Win64-Setup.exe"
44+
45+
sed -i "s|url=.*\"|url=$NEW_LINK\"|g" index.html
46+
sed -i "s|window.location.href = \".*\";|window.location.href = \"$NEW_LINK\";|g" index.html
47+
48+
git config user.name "Link Updater Bot"
49+
git config user.email "[email protected]"
50+
git add index.html
51+
git commit -m "Update download link to ${{ env.TAG_NAME }}" || echo "No changes to commit"
52+
git push
53+
54+
# ======================================================
55+
# 2. Update Portable Redirect Page
56+
# ======================================================
57+
- name: Checkout Portable Repository
58+
uses: actions/checkout@v3
59+
with:
60+
repository: AudioShelf/portable
61+
token: ${{ secrets.ORG_ADMIN_TOKEN }}
62+
path: portable-repo
63+
64+
- name: Update Portable Redirect
65+
run: |
66+
cd portable-repo
67+
NEW_LINK="https://github.com/M-Rajabi-Dev/AudioShelf/releases/download/${{ env.TAG_NAME }}/AudioShelf-${{ env.CLEAN_VERSION }}-Win64-Portable.zip"
68+
69+
sed -i "s|url=.*\"|url=$NEW_LINK\"|g" index.html
70+
sed -i "s|window.location.href = \".*\";|window.location.href = \"$NEW_LINK\";|g" index.html
71+
72+
git config user.name "Link Updater Bot"
73+
git config user.email "[email protected]"
74+
git add index.html
75+
git commit -m "Update download link to ${{ env.TAG_NAME }}" || echo "No changes to commit"
76+
git push
77+
78+
# ======================================================
79+
# 3. Update Download Hub (README & Index)
80+
# ======================================================
81+
- name: Checkout Download Hub
82+
uses: actions/checkout@v3
83+
with:
84+
repository: AudioShelf/download
85+
token: ${{ secrets.ORG_ADMIN_TOKEN }}
86+
path: download-hub
87+
88+
- name: Update Download Hub Files
89+
run: |
90+
cd download-hub
91+
SETUP_LINK="https://github.com/M-Rajabi-Dev/AudioShelf/releases/download/${{ env.TAG_NAME }}/AudioShelf-${{ env.CLEAN_VERSION }}-Win64-Setup.exe"
92+
PORTABLE_LINK="https://github.com/M-Rajabi-Dev/AudioShelf/releases/download/${{ env.TAG_NAME }}/AudioShelf-${{ env.CLEAN_VERSION }}-Win64-Portable.zip"
93+
94+
# Update README.md
95+
sed -i "s|https://AudioShelf.github.io/setup|$SETUP_LINK|g" README.md
96+
sed -i "s|https://AudioShelf.github.io/portable|$PORTABLE_LINK|g" README.md
97+
98+
# Update index.html
99+
sed -i "s|https://AudioShelf.github.io/setup|$SETUP_LINK|g" index.html
100+
sed -i "s|https://AudioShelf.github.io/portable|$PORTABLE_LINK|g" index.html
101+
102+
# Commit and Push changes
103+
git config user.name "Link Updater Bot"
104+
git config user.email "[email protected]"
105+
git add README.md index.html
106+
git commit -m "Update download hub links to ${{ env.TAG_NAME }}" || echo "No changes to commit"
107+
git push

0 commit comments

Comments
 (0)