diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e0276e6..3bffbba 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,8 +4,6 @@ on: push: branches: - "**" - tags-ignore: - - "**" pull_request: jobs: @@ -19,7 +17,9 @@ jobs: os: ubuntu-latest - identifier: windows os: ubuntu-latest + runs-on: ${{ matrix.os }} + steps: - name: Checkout project uses: actions/checkout@v4 @@ -27,26 +27,19 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version: "3.10" - name: (Windows) Install MinGW - if: ${{ startsWith(matrix.identifier, 'windows') }} + if: matrix.identifier == 'windows' run: | sudo apt-get update -y -qq sudo apt-get install -y mingw-w64 sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix - - name: (Windows) Prepare cross compilation - if: ${{ startsWith(matrix.identifier, 'windows') }} - shell: sh - run: | - echo "OS=Windows_NT" >> $GITHUB_ENV - - name: (Linux) Install dependencies - if: ${{ startsWith(matrix.identifier, 'linux') }} + if: matrix.identifier == 'linux' run: | - sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe restricted multiverse" sudo apt-get update -y -qq sudo apt-get install -y libsdl2-dev libglew-dev @@ -54,76 +47,70 @@ jobs: shell: bash run: | if [[ "${{ matrix.identifier }}" == "windows" ]]; then - make lib -j $(nproc 2>/dev/null || sysctl -n hw.ncpu) \ - CC=x86_64-w64-mingw32-gcc \ - CXX=x86_64-w64-mingw32-g++ + make lib -j $(nproc 2>/dev/null || sysctl -n hw.ncpu) \ + CC=x86_64-w64-mingw32-gcc \ + CXX=x86_64-w64-mingw32-g++ else - make lib -j $(nproc 2>/dev/null || sysctl -n hw.ncpu) + make lib -j $(nproc 2>/dev/null || sysctl -n hw.ncpu) fi - - name: (Linux) Build test executable - if: ${{ startsWith(matrix.identifier, 'linux') }} - run: | - make test -j`nproc` + - name: Build test executable (Linux only) + if: matrix.identifier == 'linux' + run: make test -j$(nproc) - - name: Upload build - uses: actions/upload-artifact@v3 + - name: Prepare artifacts + run: | + mkdir -p artifacts/${{ matrix.identifier }} + cp -r dist artifacts/${{ matrix.identifier }}/ + cp README.md artifacts/${{ matrix.identifier }}/ + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 with: name: libsm64_${{ matrix.identifier }} - path: | - ./README.md - ./dist - ./run-test + path: artifacts/${{ matrix.identifier }} Release: name: Snapshot Release runs-on: ubuntu-latest needs: Build + # IMPORTANT: prevents running on tag pushes + if: github.ref_type == 'branch' + steps: - name: Download artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 + with: + path: artifacts - - name: Create release - id: create_release - shell: bash - run: | - RESPONSE=$(curl -s -X POST \ - -H "Authorization: token ${{ secrets.LIBSM64_TOKEN }}" \ - -H "Content-Type: application/json" \ - "https://git.nepu.men/api/v1/repos/NepuShiro/libsm64/releases" \ - -d '{ - "tag_name": "latest", - "name": "Snapshot Build", - "prerelease": true - }') - - echo "$RESPONSE" - - RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -n 1 | grep -o '[0-9]*') - echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT + - name: Create Release + id: release + uses: gitea/actions/gitea-release-action@v1 + with: + api_key: ${{ secrets.GITEA_TOKEN }} + owner: NepuShiro + repo: libsm64 + tag_name: build-${{ github.sha }} + release_name: Snapshot Build ${{ github.sha }} + prerelease: true - name: Upload Linux artifact - shell: bash - run: | - curl -X POST \ - -H "Authorization: token ${{ secrets.LIBSM64_TOKEN }}" \ - -F "attachment=@libsm64_linux/run-test" \ - "https://git.nepu.men/api/v1/repos/NepuShiro/libsm64/releases/${{ steps.create_release.outputs.release_id }}/assets?name=run-test-linux" + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ steps.release.outputs.upload_url }} + asset_path: artifacts/libsm64_linux.zip + asset_name: libsm64_linux.zip + asset_content_type: application/zip + env: + GITHUB_TOKEN: ${{ secrets.GITEA_TOKEN }} - name: Upload Windows artifact - shell: bash - run: | - tar -czf windows.tar.gz libsm64_windows - curl -X POST \ - -H "Authorization: token ${{ secrets.LIBSM64_TOKEN }}" \ - -F "attachment=@windows.tar.gz" \ - "https://git.nepu.men/api/v1/repos/NepuShiro/libsm64/releases/${{ steps.create_release.outputs.release_id }}/assets?name=libsm64-windows.tar.gz" - - - name: Upload README - shell: bash - run: | - curl -X POST \ - -H "Authorization: token ${{ secrets.LIBSM64_TOKEN }}" \ - -F "attachment=@README.md" \ - "https://git.nepu.men/api/v1/repos/NepuShiro/libsm64/releases/${{ steps.create_release.outputs.release_id }}/assets?name=README.md" \ No newline at end of file + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ steps.release.outputs.upload_url }} + asset_path: artifacts/libsm64_windows.zip + asset_name: libsm64_windows.zip + asset_content_type: application/zip + env: + GITHUB_TOKEN: ${{ secrets.GITEA_TOKEN }} \ No newline at end of file