|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master ] |
| 6 | + tags: |
| 7 | + - "[0-9]+.[0-9]+.[0-9]+" |
| 8 | + - "!*.*.*-*" |
| 9 | + - "!v*.*.*" |
| 10 | + pull_request: |
| 11 | + branches: [ master ] |
| 12 | + |
| 13 | +env: |
| 14 | + BUILD_VERSION: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || format('0.0.{0}', github.run_number) }} |
| 15 | + IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/') && '1' || '0' }} |
| 16 | + |
| 17 | +jobs: |
| 18 | + prebuild: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - name: Checkout repository |
| 22 | + uses: actions/checkout@v2 |
| 23 | + |
| 24 | + - name: Validate version |
| 25 | + run: scripts/validate_version |
| 26 | + |
| 27 | + hunspell_dictionaries: |
| 28 | + needs: prebuild |
| 29 | + runs-on: ubuntu-latest |
| 30 | + steps: |
| 31 | + - name: Checkout repository |
| 32 | + uses: actions/checkout@v2 |
| 33 | + |
| 34 | + - name: Setup Python |
| 35 | + uses: actions/setup-python@v2 |
| 36 | + with: |
| 37 | + python-version: '3.x' |
| 38 | + |
| 39 | + - name: Install LXML |
| 40 | + run: pip3 install lxml |
| 41 | + |
| 42 | + - name: Build the dictionaries |
| 43 | + working-directory: packages/hunspell |
| 44 | + run: ./generate.sh |
| 45 | + |
| 46 | + - name: Upload the artifacts |
| 47 | + uses: actions/upload-artifact@v2 |
| 48 | + with: |
| 49 | + name: hunspell_dictionaries |
| 50 | + path: packages/hunspell/output/dictionaries/ |
| 51 | + |
| 52 | + chrome_extension: |
| 53 | + if: ${{ false }} |
| 54 | + needs: hunspell_dictionaries |
| 55 | + runs-on: ubuntu-latest |
| 56 | + steps: |
| 57 | + - name: Checkout repository |
| 58 | + uses: actions/checkout@v2 |
| 59 | + |
| 60 | + - name: Setup Node |
| 61 | + uses: actions/setup-node@v2 |
| 62 | + with: |
| 63 | + node-version-file: '.nvmrc' |
| 64 | + |
| 65 | + - name: Setup Chrome |
| 66 | + uses: browser-actions/setup-chrome@latest |
| 67 | + |
| 68 | + - name: Download Hunspell dictionaries |
| 69 | + uses: actions/download-artifact@v2 |
| 70 | + with: |
| 71 | + name: hunspell_dictionaries |
| 72 | + path: packages/hunspell/output/dictionaries |
| 73 | + |
| 74 | + - name: Prepare the package |
| 75 | + run: npm install |
| 76 | + env: |
| 77 | + PACKAGE_NAME: '@interslavic/hunspell-chrome-extension' |
| 78 | + |
| 79 | + - name: Build the extension |
| 80 | + run: npm run build |
| 81 | + working-directory: packages/chrome |
| 82 | + |
| 83 | + - name: Upload the artifacts |
| 84 | + uses: actions/upload-artifact@v2 |
| 85 | + with: |
| 86 | + name: chrome_extension |
| 87 | + path: packages/chrome/dist/ |
| 88 | + |
| 89 | + firefox_extension: |
| 90 | + needs: hunspell_dictionaries |
| 91 | + runs-on: ubuntu-latest |
| 92 | + steps: |
| 93 | + - name: Checkout repository |
| 94 | + uses: actions/checkout@v2 |
| 95 | + |
| 96 | + - name: Setup Node |
| 97 | + uses: actions/setup-node@v2 |
| 98 | + with: |
| 99 | + node-version-file: '.nvmrc' |
| 100 | + |
| 101 | + - name: Download Hunspell dictionaries |
| 102 | + uses: actions/download-artifact@v2 |
| 103 | + with: |
| 104 | + name: hunspell_dictionaries |
| 105 | + path: packages/hunspell/output/dictionaries |
| 106 | + |
| 107 | + - name: Prepare the package |
| 108 | + run: npm install |
| 109 | + env: |
| 110 | + PACKAGE_NAME: '@interslavic/hunspell-firefox-extension' |
| 111 | + |
| 112 | + - name: Build an unsigned extension |
| 113 | + if: ${{ env.IS_RELEASE == '0' }} |
| 114 | + run: npm run build |
| 115 | + working-directory: packages/firefox |
| 116 | + |
| 117 | + - name: Build a signed extension |
| 118 | + if: ${{ env.IS_RELEASE == '1' }} |
| 119 | + run: npm run sign |
| 120 | + working-directory: packages/firefox |
| 121 | + env: |
| 122 | + MOZILLA_API_KEY: ${{ secrets.MOZILLA_API_KEY }} |
| 123 | + MOZILLA_API_SECRET: ${{ secrets.MOZILLA_API_SECRET }} |
| 124 | + |
| 125 | + - name: Upload the artifacts |
| 126 | + uses: actions/upload-artifact@v2 |
| 127 | + with: |
| 128 | + name: firefox_extension |
| 129 | + path: packages/firefox/dist/ |
| 130 | + |
| 131 | + libreoffice_extension: |
| 132 | + needs: hunspell_dictionaries |
| 133 | + runs-on: ubuntu-latest |
| 134 | + steps: |
| 135 | + - name: Checkout repository |
| 136 | + uses: actions/checkout@v2 |
| 137 | + |
| 138 | + - name: Setup Node |
| 139 | + uses: actions/setup-node@v2 |
| 140 | + with: |
| 141 | + node-version-file: '.nvmrc' |
| 142 | + |
| 143 | + - name: Download Hunspell dictionaries |
| 144 | + uses: actions/download-artifact@v2 |
| 145 | + with: |
| 146 | + name: hunspell_dictionaries |
| 147 | + path: packages/hunspell/output/dictionaries |
| 148 | + |
| 149 | + - name: Prepare the package |
| 150 | + run: npm install |
| 151 | + env: |
| 152 | + PACKAGE_NAME: '@interslavic/hunspell-libreoffice-extension' |
| 153 | + |
| 154 | + - name: Build the extension |
| 155 | + run: npm run build |
| 156 | + working-directory: packages/libreoffice |
| 157 | + |
| 158 | + - name: Upload the artifacts |
| 159 | + uses: actions/upload-artifact@v2 |
| 160 | + with: |
| 161 | + name: libreoffice_extension |
| 162 | + path: packages/libreoffice/dist/ |
| 163 | + |
| 164 | + npm_package: |
| 165 | + needs: hunspell_dictionaries |
| 166 | + runs-on: ubuntu-latest |
| 167 | + steps: |
| 168 | + - name: Checkout repository |
| 169 | + uses: actions/checkout@v2 |
| 170 | + |
| 171 | + - name: Setup Node |
| 172 | + uses: actions/setup-node@v2 |
| 173 | + with: |
| 174 | + node-version-file: '.nvmrc' |
| 175 | + |
| 176 | + - name: Download Hunspell dictionaries |
| 177 | + uses: actions/download-artifact@v2 |
| 178 | + with: |
| 179 | + name: hunspell_dictionaries |
| 180 | + path: packages/hunspell/output/dictionaries |
| 181 | + |
| 182 | + - name: Prepare the package |
| 183 | + run: npm install |
| 184 | + env: |
| 185 | + PACKAGE_NAME: '@interslavic/hunspell-dictionary' |
| 186 | + |
| 187 | + - name: Test the package |
| 188 | + run: npm test |
| 189 | + working-directory: packages/npm |
| 190 | + |
| 191 | + - name: Pack the package |
| 192 | + run: 'npm version "$BUILD_VERSION" && npm pack' |
| 193 | + working-directory: packages/npm |
| 194 | + |
| 195 | + - name: Rename TGZ file |
| 196 | + run: npm run rename |
| 197 | + working-directory: packages/npm |
| 198 | + |
| 199 | + - name: Upload the artifacts |
| 200 | + uses: actions/upload-artifact@v2 |
| 201 | + with: |
| 202 | + name: npm_package |
| 203 | + path: 'packages/npm/*.tgz' |
| 204 | + |
| 205 | + publish: |
| 206 | + if: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 207 | + needs: |
| 208 | + - hunspell_dictionaries |
| 209 | + - firefox_extension |
| 210 | + - libreoffice_extension |
| 211 | + - npm_package |
| 212 | + runs-on: ubuntu-latest |
| 213 | + steps: |
| 214 | + - name: Setup Node |
| 215 | + uses: actions/setup-node@v2 |
| 216 | + |
| 217 | + - name: Download the dictionaries |
| 218 | + uses: actions/download-artifact@v2 |
| 219 | + with: |
| 220 | + name: hunspell_dictionaries |
| 221 | + path: .temp |
| 222 | + |
| 223 | + - name: Download Chrome extension |
| 224 | + if: ${{ false }} |
| 225 | + uses: actions/download-artifact@v2 |
| 226 | + with: |
| 227 | + name: chrome_extension |
| 228 | + path: .temp |
| 229 | + |
| 230 | + - name: Download Firefox extension |
| 231 | + uses: actions/download-artifact@v2 |
| 232 | + with: |
| 233 | + name: firefox_extension |
| 234 | + path: .temp |
| 235 | + |
| 236 | + - name: Download Libreoffice extension |
| 237 | + uses: actions/download-artifact@v2 |
| 238 | + with: |
| 239 | + name: libreoffice_extension |
| 240 | + path: .temp |
| 241 | + |
| 242 | + - name: Download NPM package |
| 243 | + uses: actions/download-artifact@v2 |
| 244 | + with: |
| 245 | + name: npm_package |
| 246 | + path: .temp |
| 247 | + |
| 248 | + - name: List the artifacts |
| 249 | + run: ls -R |
| 250 | + working-directory: .temp |
| 251 | + |
| 252 | + - name: Publish a release |
| 253 | + uses: softprops/action-gh-release@v1 |
| 254 | + with: |
| 255 | + draft: true |
| 256 | + files: '.temp/*' |
| 257 | + generate_release_notes: true |
| 258 | + |
| 259 | + - name: Publish to NPM |
| 260 | + run: npm publish .temp/*-npm-*.tgz |
0 commit comments