name: Release on: push: tags: - 'v*' env: CARGO_TERM_COLOR: always jobs: build: runs-on: ubuntu-latest strategy: matrix: include: - arch: x86_64 target: x86_64-unknown-linux-gnu - arch: aarch64 target: aarch64-unknown-linux-gnu steps: - uses: actions/checkout@v4 - name: Install system dependencies run: | sudo apt-get update sudo apt-get install -y libwayland-dev pkg-config - name: Install cross-compilation tools (aarch64 only) if: matrix.arch == 'aarch64' run: | sudo apt-get install -y gcc-aarch64-linux-gnu echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV - name: Install Rust stable uses: dtolnay/rust-toolchain@stable with: targets: ${{ matrix.target }} - name: Cache cargo registry uses: actions/cache@v3 with: path: ~/.cargo/registry key: ${{ runner.os }}-${{ matrix.arch }}-cargo-${{ hashFiles('Cargo.lock') }} - name: Build run: cargo build --release --target ${{ matrix.target }} - name: Package run: | VERSION="${{ gitea.ref_name }}" TARBALL="gpupaper-${VERSION}-${{ matrix.arch }}.tar.gz" mkdir -p pkg cp target/${{ matrix.target }}/release/gpupaper pkg/ cp -r shaders pkg/ cp LICENSE pkg/ tar -czf "${TARBALL}" -C pkg . sha256sum "${TARBALL}" > "${TARBALL}.sha256" echo "TARBALL=${TARBALL}" >> $GITHUB_ENV # --------------------------------------------------------------------------- # Upload to a PUBLIC Gitea repo used as a release mirror. # Set RELEASE_REPO in repository secrets to "user/public-releases-repo". # The token needs write access to that repo. # --------------------------------------------------------------------------- - name: Create release in mirror repo (if not already exists) if: matrix.arch == 'x86_64' run: | curl -sX POST \ -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \ -H "Content-Type: application/json" \ "${{ gitea.server_url }}/api/v1/repos/${{ secrets.RELEASE_REPO }}/releases" \ -d "{\"tag_name\":\"${{ gitea.ref_name }}\",\"name\":\"${{ gitea.ref_name }}\",\"body\":\"\"}" \ --fail-with-body || true # ignore if release already exists - name: Get release ID from mirror repo run: | RELEASE_ID=$(curl -sX GET \ -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \ "${{ gitea.server_url }}/api/v1/repos/${{ secrets.RELEASE_REPO }}/releases/tags/${{ gitea.ref_name }}" \ | jq -r '.id') echo "RELEASE_ID=${RELEASE_ID}" >> $GITHUB_ENV - name: Upload binary asset run: | curl -sX POST \ -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \ -H "Content-Type: application/octet-stream" \ "${{ gitea.server_url }}/api/v1/repos/${{ secrets.RELEASE_REPO }}/releases/${{ env.RELEASE_ID }}/assets?name=${{ env.TARBALL }}" \ --data-binary "@${{ env.TARBALL }}" --fail-with-body - name: Upload checksum run: | curl -sX POST \ -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \ -H "Content-Type: text/plain" \ "${{ gitea.server_url }}/api/v1/repos/${{ secrets.RELEASE_REPO }}/releases/${{ env.RELEASE_ID }}/assets?name=${{ env.TARBALL }}.sha256" \ --data-binary "@${{ env.TARBALL }}.sha256" --fail-with-body