|
| 1 | +name: Build, Update Webpage, and Deploy |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + release: |
| 8 | + types: [published] |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +jobs: |
| 12 | + build-executable: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + steps: |
| 16 | + # Step 1: Checkout the repository |
| 17 | + - name: Checkout repository |
| 18 | + uses: actions/checkout@v3 |
| 19 | + |
| 20 | + # Step 2: Set up Python environment |
| 21 | + - name: Set up Python |
| 22 | + uses: actions/setup-python@v4 |
| 23 | + with: |
| 24 | + python-version: 3.12 |
| 25 | + |
| 26 | + # Step 3: Install dependencies |
| 27 | + - name: Install dependencies |
| 28 | + run: | |
| 29 | + python -m pip install --upgrade pip |
| 30 | + pip install -r requirements.txt |
| 31 | + pip install pyinstaller |
| 32 | +
|
| 33 | + # Step 4: Build the executable |
| 34 | + - name: Build executable |
| 35 | + run: | |
| 36 | + pyinstaller --noconfirm --noconsole --icon=file_renamer_icon.ico --add-data "file_renamer_icon.ico;." --hidden-import=pillow_heif --hidden-import=pytz.zoneinfo --exclude-module numpy --exclude-module mkl --exclude-module tcl --exclude-module tbb --exclude-module pywin32 --exclude-module psutil rename_files.py |
| 37 | +
|
| 38 | + # Step 5: Upload as artifact |
| 39 | + - name: Upload executable artifact |
| 40 | + uses: actions/upload-artifact@v3 |
| 41 | + with: |
| 42 | + name: rename_files_executable |
| 43 | + path: dist/rename_files/rename_files.exe |
| 44 | + |
| 45 | + update-gh-pages: |
| 46 | + runs-on: ubuntu-latest |
| 47 | + needs: build-executable |
| 48 | + if: github.event_name == 'push' |
| 49 | + |
| 50 | + steps: |
| 51 | + # Step 1: Checkout the repository |
| 52 | + - name: Checkout repository |
| 53 | + uses: actions/checkout@v3 |
| 54 | + |
| 55 | + # Step 2: Update webpage content (no executable update) |
| 56 | + - name: Update webpage |
| 57 | + run: | |
| 58 | + mkdir gh-pages |
| 59 | + echo '<!DOCTYPE html> |
| 60 | + <html lang="en"> |
| 61 | + <head> |
| 62 | + <meta charset="UTF-8"> |
| 63 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 64 | + <title>File Renamer</title> |
| 65 | + <style> |
| 66 | + body { |
| 67 | + font-family: Arial, sans-serif; |
| 68 | + margin: 0; |
| 69 | + padding: 0; |
| 70 | + text-align: center; |
| 71 | + background-color: #f9f9f9; |
| 72 | + color: #333; |
| 73 | + } |
| 74 | + header { |
| 75 | + background-color: #4CAF50; |
| 76 | + color: white; |
| 77 | + padding: 1rem; |
| 78 | + } |
| 79 | + main { |
| 80 | + padding: 2rem; |
| 81 | + } |
| 82 | + a.download-btn { |
| 83 | + display: inline-block; |
| 84 | + margin-top: 20px; |
| 85 | + padding: 10px 20px; |
| 86 | + color: white; |
| 87 | + background-color: #007BFF; |
| 88 | + text-decoration: none; |
| 89 | + border-radius: 5px; |
| 90 | + } |
| 91 | + a.download-btn:hover { |
| 92 | + background-color: #0056b3; |
| 93 | + } |
| 94 | + </style> |
| 95 | + </head> |
| 96 | + <body> |
| 97 | + <header> |
| 98 | + <h1>File Renamer</h1> |
| 99 | + </header> |
| 100 | + <main> |
| 101 | + <p>Welcome to the official page for <strong>File Renamer</strong>. Simplify file renaming with powerful features like metadata-based sorting and intuitive GUI support.</p> |
| 102 | + <h2>Download</h2> |
| 103 | + <p>The latest release is available below:</p> |
| 104 | + <a class="download-btn" href="rename_files.exe">Download File Renamer</a> |
| 105 | + <h2>Features</h2> |
| 106 | + <ul> |
| 107 | + <li>Renames files based on metadata like date taken.</li> |
| 108 | + <li>Supports multiple file formats, including images and videos.</li> |
| 109 | + <li>Provides fallback options for missing metadata.</li> |
| 110 | + </ul> |
| 111 | + <h2>Need Help?</h2> |
| 112 | + <p>For more information or to report bugs, visit the <a href="https://github.com/dcwelch/file_renamer/issues">GitHub Issues page</a>.</p> |
| 113 | + </main> |
| 114 | + </body> |
| 115 | + </html>' > gh-pages/index.html |
| 116 | +
|
| 117 | + - name: Deploy to GitHub Pages |
| 118 | + uses: peaceiris/actions-gh-pages@v3 |
| 119 | + with: |
| 120 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 121 | + publish_dir: gh-pages |
| 122 | + |
| 123 | + update-gh-pages-release: |
| 124 | + runs-on: ubuntu-latest |
| 125 | + needs: build-executable |
| 126 | + if: github.event_name == 'release' |
| 127 | + |
| 128 | + steps: |
| 129 | + # Step 1: Checkout the repository |
| 130 | + - name: Checkout repository |
| 131 | + uses: actions/checkout@v3 |
| 132 | + |
| 133 | + # Step 2: Update webpage content (with executable update) |
| 134 | + - name: Update webpage with release executable |
| 135 | + run: | |
| 136 | + mkdir gh-pages |
| 137 | + cp dist/rename_files/rename_files.exe gh-pages/ |
| 138 | + echo '<!DOCTYPE html> |
| 139 | + <html lang="en"> |
| 140 | + <head> |
| 141 | + <meta charset="UTF-8"> |
| 142 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 143 | + <title>File Renamer</title> |
| 144 | + <style> |
| 145 | + body { |
| 146 | + font-family: Arial, sans-serif; |
| 147 | + margin: 0; |
| 148 | + padding: 0; |
| 149 | + text-align: center; |
| 150 | + background-color: #f9f9f9; |
| 151 | + color: #333; |
| 152 | + } |
| 153 | + header { |
| 154 | + background-color: #4CAF50; |
| 155 | + color: white; |
| 156 | + padding: 1rem; |
| 157 | + } |
| 158 | + main { |
| 159 | + padding: 2rem; |
| 160 | + } |
| 161 | + a.download-btn { |
| 162 | + display: inline-block; |
| 163 | + margin-top: 20px; |
| 164 | + padding: 10px 20px; |
| 165 | + color: white; |
| 166 | + background-color: #007BFF; |
| 167 | + text-decoration: none; |
| 168 | + border-radius: 5px; |
| 169 | + } |
| 170 | + a.download-btn:hover { |
| 171 | + background-color: #0056b3; |
| 172 | + } |
| 173 | + </style> |
| 174 | + </head> |
| 175 | + <body> |
| 176 | + <header> |
| 177 | + <h1>File Renamer</h1> |
| 178 | + </header> |
| 179 | + <main> |
| 180 | + <p>Welcome to the official page for <strong>File Renamer</strong>. Simplify file renaming with powerful features like metadata-based sorting and intuitive GUI support.</p> |
| 181 | + <h2>Download</h2> |
| 182 | + <p>Click the button below to download the latest version:</p> |
| 183 | + <a class="download-btn" href="rename_files.exe">Download File Renamer</a> |
| 184 | + <h2>Features</h2> |
| 185 | + <ul> |
| 186 | + <li>Renames files based on metadata like date taken.</li> |
| 187 | + <li>Supports multiple file formats, including images and videos.</li> |
| 188 | + <li>Provides fallback options for missing metadata.</li> |
| 189 | + </ul> |
| 190 | + <h2>Need Help?</h2> |
| 191 | + <p>For more information or to report bugs, visit the <a href="https://github.com/dcwelch/file_renamer/issues">GitHub Issues page</a>.</p> |
| 192 | + </main> |
| 193 | + </body> |
| 194 | + </html>' > gh-pages/index.html |
| 195 | +
|
| 196 | + - name: Deploy to GitHub Pages |
| 197 | + uses: peaceiris/actions-gh-pages@v3 |
| 198 | + with: |
| 199 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 200 | + publish_dir: gh-pages |
0 commit comments