chore: fix build #56
This file contains 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-torrserver | |
#on: | |
# release: | |
# types: [published] | |
on: [push, pull_request] | |
jobs: | |
checkTSVersion: | |
runs-on: ubuntu-latest | |
outputs: | |
run_build_assets: ${{ steps.set_output.outputs.build_assets }} | |
ts_version_latest: ${{ steps.set_output.outputs.ts_version }} | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 1 | |
- name: Get latest TorrServer version | |
run: | | |
TS_VERSION_LATEST="$(curl -sL https://api.github.com/repos/YouROK/TorrServer/releases/latest | jq -r '.tag_name')" | |
echo "TS_VERSION_LATEST=${TS_VERSION_LATEST}" >> ${GITHUB_ENV} | |
- name: Check local version | |
id: set_output | |
working-directory: ./torrserver | |
run: | | |
TS_VERSION_ASSETS=$(cat TS_VERSION) | |
echo "TS version latest: ${TS_VERSION_LATEST}" | |
echo "TS version assets: ${TS_VERSION_ASSETS}" | |
if [[ "$TS_VERSION_LATEST" != "$TS_VERSION_ASSETS" ]]; then | |
echo "Latest version is not equal version in assets" | |
echo "build_assets=true" >> "$GITHUB_OUTPUT" | |
echo "ts_version=${TS_VERSION_LATEST}" >> "$GITHUB_OUTPUT" | |
else | |
echo "Latest version is the same as in assets" | |
echo "build_assets=false" >> "$GITHUB_OUTPUT" | |
fi | |
buildAssets: | |
needs: [checkTSVersion] | |
if: needs.checkTSVersion.outputs.run_build_assets == 'true' | |
runs-on: ubuntu-latest | |
env: | |
TS_VERSION: ${{ needs.checkTSVersion.outputs.ts_version_latest }} | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Set Node.js 16.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 16.x | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: "^1.21.2" | |
- name: Prepare TorrServer source | |
working-directory: ./torrserver/.build | |
run: | | |
rm -rf TorrServer | |
git clone --depth 1 --branch $TS_VERSION https://github.com/YouROK/TorrServer.git | |
cp ./build-all.sh ./TorrServer/build-all.sh | |
jq -c '. + { "homepage": "./" }' ./TorrServer/web/package.json --indent 2 > ./TorrServer/web/package.$$.json && mv ./TorrServer/web/package.$$.json ./TorrServer/web/package.json | |
cat ./TorrServer/web/package.json | |
- name: Run build | |
env: | |
REACT_APP_SERVER_HOST: "." | |
working-directory: ./torrserver/.build/TorrServer | |
run: | | |
yarn --cwd ./web install && yarn --cwd ./web run build | |
./build-all.sh | |
# - name: Copy versi | |
# working-directory: ./torrserver | |
# run: | | |
# echo $TS_VERSION > ./VERSION | |
- name: Release | |
uses: actions/create-release@v1 | |
id: create_release | |
with: | |
draft: false | |
prerelease: false | |
release_name: ${{ env.TS_VERSION }} | |
tag_name: ${{ env.TS_VERSION }} | |
body: Bump ${{ env.TS_VERSION }} | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: upload armv7 | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./torrserver/.build/TorrServer/dist/TorrServer-linux-arm7 | |
asset_name: TorrServer-arm7 | |
asset_content_type: application/octet-stream | |
- name: upload armv7 | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./torrserver/.build/TorrServer/dist/TorrServer-linux-arm7 | |
asset_name: TorrServer-armhf | |
asset_content_type: application/octet-stream | |
- name: upload amd64 | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./torrserver/.build/TorrServer/dist/TorrServer-linux-amd64 | |
asset_name: TorrServer-amd64 | |
asset_content_type: application/octet-stream | |
- name: upload i386 | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./torrserver/.build/TorrServer/dist/TorrServer-linux-386 | |
asset_name: TorrServer-i386 | |
asset_content_type: application/octet-stream | |
- name: upload aarch64 | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./torrserver/.build/TorrServer/dist/TorrServer-linux-arm64 | |
asset_name: TorrServer-aarch64 | |
asset_content_type: application/octet-stream |