Simplify GitHub Actions #49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Publish | |
| on: | |
| push: | |
| branches: | |
| - '*' | |
| tags: | |
| - '*' | |
| paths: | |
| - '**' | |
| workflow_dispatch: | |
| permissions: | |
| id-token: write | |
| attestations: write | |
| contents: write | |
| jobs: | |
| build_and_release: | |
| runs-on: 'ubuntu-latest' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install toolchain dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y clang lld bsdextrautils | |
| - name: Checkout PS5 payload SDK | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ps5-payload-dev/sdk | |
| ref: 9e4b1ad7642ecf6e6a9bca7025b574034ee63ca7 | |
| submodules: recursive | |
| path: ps5-payload-sdk | |
| - name: Build and install SDK | |
| run: | | |
| export PS5_PAYLOAD_SDK="$GITHUB_WORKSPACE/ps5-sdk" | |
| make -C ps5-payload-sdk DESTDIR="$PS5_PAYLOAD_SDK" clean install | |
| echo "PS5_PAYLOAD_SDK=$PS5_PAYLOAD_SDK" >> "$GITHUB_ENV" | |
| - name: Build mounter payload | |
| run: make -C mounter_payload | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 8.0.x | |
| - name: Publish | |
| run: | | |
| dotnet publish PS4Saves.csproj --configuration Release \ | |
| -p:EnableWindowsTargeting=true --output ./publish/win-x64 | |
| cp mounter_payload/mounter.elf ./publish/win-x64/ | |
| cd ./publish/win-x64 | |
| zip -r save-mounter.zip ./* | |
| - name: Attest | |
| uses: actions/attest-build-provenance@v1 | |
| with: | |
| subject-path: ./publish/win-x64/save-mounter.zip | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: save-mounter.zip | |
| path: ./publish/win-x64/save-mounter.zip | |
| - name: Create or Update GitHub Release | |
| if: startsWith(github.ref, 'refs/tags/') | |
| shell: bash | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG_NAME=${GITHUB_REF#refs/tags/} | |
| RELEASE_EXISTS=$(gh release view $TAG_NAME > /dev/null 2>&1; echo $?) | |
| if [ $RELEASE_EXISTS -eq 0 ]; then | |
| echo "Release $TAG_NAME already exists. Uploading assets..." | |
| gh release upload $TAG_NAME ./publish/win-x64/save-mounter.zip | |
| else | |
| echo "Creating new release $TAG_NAME..." | |
| gh release create $TAG_NAME --verify-tag -d ./publish/win-x64/save-mounter.zip | |
| fi |