|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [ main ] |
| 6 | + push: |
| 7 | + tags: |
| 8 | + - "v*" |
| 9 | + workflow_dispatch: # allows manual run too |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + container: |
| 15 | + image: fozztexx/defoogi:1.4.2 |
| 16 | + |
| 17 | + outputs: |
| 18 | + files: ${{ steps.list_zips.outputs.files }} |
| 19 | + |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Build release files |
| 24 | + run: make release |
| 25 | + |
| 26 | + - name: List zip files |
| 27 | + id: list_zips |
| 28 | + shell: bash |
| 29 | + run: | |
| 30 | + echo 'files=["'"$(( cd dist ; echo *.zip ) | sed -e 's/ /","/g')"'"]' >> $GITHUB_OUTPUT |
| 31 | +
|
| 32 | + - name: Upload dist folder for next job |
| 33 | + uses: actions/upload-artifact@v4 |
| 34 | + with: |
| 35 | + name: dist |
| 36 | + path: dist/ |
| 37 | + |
| 38 | + upload: |
| 39 | + needs: build |
| 40 | + runs-on: ubuntu-latest |
| 41 | + if: github.event_name == 'pull_request' |
| 42 | + strategy: |
| 43 | + matrix: |
| 44 | + file: ${{ fromJson(needs.build.outputs.files) }} |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v4 |
| 47 | + |
| 48 | + - name: Download dist folder |
| 49 | + uses: actions/download-artifact@v4 |
| 50 | + with: |
| 51 | + name: dist |
| 52 | + path: dist |
| 53 | + |
| 54 | + - name: Upload individual artifact |
| 55 | + uses: actions/upload-artifact@v4 |
| 56 | + with: |
| 57 | + name: ${{ matrix.file }} |
| 58 | + path: dist/${{ matrix.file }} |
| 59 | + |
| 60 | + tagged-release: |
| 61 | + needs: build |
| 62 | + runs-on: ubuntu-latest |
| 63 | + if: startsWith(github.ref, 'refs/tags/') |
| 64 | + steps: |
| 65 | + - uses: actions/checkout@v4 |
| 66 | + |
| 67 | + # Download the dist folder from the build job |
| 68 | + - name: Download build artifacts |
| 69 | + uses: actions/download-artifact@v4 |
| 70 | + with: |
| 71 | + name: dist |
| 72 | + path: dist |
| 73 | + |
| 74 | + # Generate random release name |
| 75 | + - name: Generate random release name |
| 76 | + id: random_name |
| 77 | + run: | |
| 78 | + RANDOM_NAME=$(docker run --rm fnichol/names) |
| 79 | + echo "name=$RANDOM_NAME" >> $GITHUB_OUTPUT |
| 80 | + echo "Generated release name: $RANDOM_NAME" |
| 81 | +
|
| 82 | + # Create GitHub Release for the tag |
| 83 | + - name: Create GitHub Release |
| 84 | + id: create_release |
| 85 | + uses: actions/create-release@v1 |
| 86 | + with: |
| 87 | + tag_name: ${{ github.ref_name }} |
| 88 | + release_name: ${{ steps.random_name.outputs.name }} (${{ github.ref_name }}) |
| 89 | + draft: false |
| 90 | + prerelease: false |
| 91 | + env: |
| 92 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 93 | + |
| 94 | + # Upload each zip as a release asset |
| 95 | + - name: Upload release assets |
| 96 | + run: | |
| 97 | + for zip in dist/*.zip; do |
| 98 | + echo "Uploading $zip..." |
| 99 | + gh release upload ${{ github.ref_name }} "$zip" |
| 100 | + done |
| 101 | + env: |
| 102 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments