|
| 1 | +name: Build Platform Target |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + repository_dispatch: |
| 6 | + types: ['build-ready'] |
| 7 | + push: |
| 8 | + branches: ['main'] |
| 9 | + tags: |
| 10 | + - '**' |
| 11 | + |
| 12 | +env: |
| 13 | + ITCH_IO_PUBLISH: 'true' |
| 14 | + # Set ITCH_IO_API_KEY in Repository Secrets |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + outputs: |
| 20 | + TAG_PUSH: ${{ steps.setenv.outputs.TAG_PUSH }} |
| 21 | + PRERELEASE: ${{ steps.setenv.outputs.PRERELEASE }} |
| 22 | + GIT_TAG: ${{ steps.setenv.outputs.GIT_TAG }} |
| 23 | + ITCH_IO_PUBLISH: ${{ steps.setenv.outputs.ITCH_IO_PUBLISH }} |
| 24 | + TAG_NAME: ${{ steps.tag.outputs.TAG_NAME }} |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + fetch-depth: 0 |
| 30 | + fetch-tags: 'true' |
| 31 | + |
| 32 | + - name: Set env |
| 33 | + id: setenv |
| 34 | + run: | |
| 35 | + echo "Github Action Event: ${{ github.event_name }}" |
| 36 | +
|
| 37 | + # If HEAD commit contains tag, event is tag push or manual workflow dispatch rerun |
| 38 | + if [ -n "$(git tag -l --contains HEAD)" ] && \ |
| 39 | + [ ${{ github.event_name }} != "repository_dispatch" ]; then \ |
| 40 | + echo "Tagged Release"; \ |
| 41 | + TAG_PUSH=true; \ |
| 42 | + PRERELEASE=false; \ |
| 43 | + else \ |
| 44 | + echo "Rolling Release"; \ |
| 45 | + TAG_PUSH=false; \ |
| 46 | + PRERELEASE=true; \ |
| 47 | + fi |
| 48 | +
|
| 49 | + GIT_TAG="$( git describe --tags --abbrev=0 )" |
| 50 | + GIT_TAG=${GIT_TAG:=0.0.1} |
| 51 | +
|
| 52 | + echo "TAG_PUSH=${TAG_PUSH}" >> $GITHUB_OUTPUT |
| 53 | + echo "PRERELEASE=${PRERELEASE}" >> $GITHUB_OUTPUT |
| 54 | + echo "GIT_TAG=${GIT_TAG}" >> $GITHUB_OUTPUT |
| 55 | +
|
| 56 | + echo "ITCH_IO_PUBLISH=${{ env.ITCH_IO_PUBLISH }}" >> $GITHUB_OUTPUT |
| 57 | +
|
| 58 | + - name: Docker build project |
| 59 | + id: docker |
| 60 | + uses: ./docker/build-project |
| 61 | + with: |
| 62 | + repo: ${{ github.repository }} |
| 63 | + nightly: ${{ steps.setenv.outputs.PRERELEASE }} |
| 64 | + |
| 65 | + - name: Upload Build Artifacts |
| 66 | + uses: actions/upload-artifact@v4 |
| 67 | + with: |
| 68 | + name: xr-grid |
| 69 | + path: ${{ github.workspace }}/releases |
| 70 | + |
| 71 | + - name: Set tag name |
| 72 | + id: tag |
| 73 | + run: | |
| 74 | + TAG_NAME="$( echo "${{ steps.docker.outputs.VERSION_TAG }}" | cut -d '-' -f1 )" |
| 75 | +
|
| 76 | + # Rolling release tag |
| 77 | + if [ ${{ steps.setenv.outputs.TAG_PUSH }} == "false" ]; then \ |
| 78 | + TAG_DATE="$( date +"%Y-%m-%dT%H%M%S" )"; \ |
| 79 | + TAG_VERSION="$( echo "${{ steps.docker.outputs.VERSION_TAG }}" | cut -d '-' -f2- )"; \ |
| 80 | + TAG_NAME="${TAG_NAME}-nightly-${TAG_DATE}-${TAG_VERSION}"; \ |
| 81 | + fi |
| 82 | +
|
| 83 | + echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_OUTPUT |
| 84 | +
|
| 85 | + release: |
| 86 | + runs-on: ubuntu-latest |
| 87 | + needs: build |
| 88 | + if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }} |
| 89 | + env: |
| 90 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 91 | + steps: |
| 92 | + - name: Create Release |
| 93 | + id: create_release |
| 94 | + uses: actions/create-release@v1 |
| 95 | + with: |
| 96 | + tag_name: ${{ needs.build.outputs.TAG_NAME }} |
| 97 | + release_name: ${{ needs.build.outputs.TAG_NAME }} V-Sekai Game Release |
| 98 | + draft: false |
| 99 | + prerelease: ${{ needs.build.outputs.PRERELEASE }} |
| 100 | + |
| 101 | + - name: Download Artifacts |
| 102 | + uses: actions/download-artifact@v4 |
| 103 | + with: |
| 104 | + path: xr-grid |
| 105 | + name: xr-grid |
| 106 | + |
| 107 | + - name: Upload Release Asset |
| 108 | + run: | |
| 109 | + echo "Release Tag: ${{ needs.build.outputs.TAG_NAME }}." |
| 110 | + cd xr-grid |
| 111 | + echo "Uploading to ${{ steps.create_release.outputs.upload_url }}" |
| 112 | + for file in *; do \ |
| 113 | + echo "Uploading $file..."; \ |
| 114 | + curl -L \ |
| 115 | + -X POST \ |
| 116 | + -H "Accept: application/vnd.github+json" \ |
| 117 | + -H "Authorization: Bearer ${GITHUB_TOKEN}" \ |
| 118 | + -H "Content-Type: application/octet-stream" \ |
| 119 | + "https://uploads.github.com/repos/${{ github.repository }}/releases/${{ steps.create_release.outputs.id }}/assets?name=${file}" \ |
| 120 | + -T "${file}"; \ |
| 121 | + done |
| 122 | +
|
| 123 | + itch-upload: |
| 124 | + runs-on: ubuntu-latest |
| 125 | + needs: [build] |
| 126 | + |
| 127 | + # Publish only on v-sekai-game tag update |
| 128 | + if: needs.build.outputs.ITCH_IO_PUBLISH == 'true' && needs.build.outputs.TAG_PUSH == 'true' |
| 129 | + steps: |
| 130 | + - name: Checkout |
| 131 | + uses: actions/checkout@v4 |
| 132 | + with: |
| 133 | + sparse-checkout: | |
| 134 | + ./docker/itch-io/ |
| 135 | +
|
| 136 | + - name: Download Artifacts |
| 137 | + uses: actions/download-artifact@v4 |
| 138 | + with: |
| 139 | + path: ${{ github.workspace }}/xr-grid |
| 140 | + name: xr-grid |
| 141 | + |
| 142 | + - name: Docker Itch.io Publish |
| 143 | + uses: ./docker/itch-io |
| 144 | + with: |
| 145 | + api_key: ${{ secrets.ITCH_IO_API_KEY }} |
| 146 | + filepath: xr-grid |
| 147 | + itchio_project: projectname |
| 148 | + release_version: ${{ needs.build.outputs.GIT_TAG }} |
0 commit comments