|
| 1 | +# This triggers whenever a tagged release is pushed |
| 2 | +name: Compile Assets and Create Draft Release |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - 'v*' # Trigger on tags beginning with 'v' |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout Repository |
| 15 | + uses: actions/checkout@v2 |
| 16 | + |
| 17 | + - name: Install Flutter |
| 18 | + uses: subosito/flutter-action@v2 |
| 19 | + with: |
| 20 | + flutter-version: '3.x' |
| 21 | + channel: 'stable' |
| 22 | + |
| 23 | + - name: Install Melos |
| 24 | + run: flutter pub global activate melos |
| 25 | + |
| 26 | + - name: Install dependencies and compile assets |
| 27 | + run: melos prepare |
| 28 | + |
| 29 | + # Extract the tag name from the event payload |
| 30 | + - name: Get Tag Name |
| 31 | + id: get_tag_name |
| 32 | + run: echo ::set-output name=tag_name::${GITHUB_REF/refs\/tags\//} |
| 33 | + |
| 34 | + # Determine if the release should be a prerelease (true if the version contains "-") |
| 35 | + - name: Determine Prerelease |
| 36 | + id: determine_prerelease |
| 37 | + run: echo ::set-output name=is_prerelease::$(echo ${{ steps.get_tag_name.outputs.tag_name }} | grep -q "-" && echo "true" || echo "false") |
| 38 | + |
| 39 | + # Create the Draft release using the tag name |
| 40 | + - name: Create Draft Release |
| 41 | + id: create_release |
| 42 | + uses: actions/create-release@v1 |
| 43 | + env: |
| 44 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 45 | + with: |
| 46 | + tag_name: ${{ steps.get_tag_name.outputs.tag_name }} # Use the pushed tag name |
| 47 | + release_name: Release ${{ steps.get_tag_name.outputs.tag_name }} |
| 48 | + draft: true |
| 49 | + prerelease: ${{ steps.determine_prerelease.outputs.is_prerelease }} |
| 50 | + |
| 51 | + # Upload the compiled assets to the Draft release. |
| 52 | + - name: Upload Assets to Draft Release |
| 53 | + id: upload-release-asset |
| 54 | + uses: actions/upload-release-asset@v1 |
| 55 | + env: |
| 56 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 57 | + with: |
| 58 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 59 | + asset_path: ./assets/powersync_db.worker.js |
| 60 | + asset_name: powersync_db.worker.js |
| 61 | + asset_content_type: text/javascript |
0 commit comments