|
| 1 | +name: Release On version tags |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v[0-9]+.[0-9]+.[0-9]*" |
| 7 | + |
| 8 | +jobs: |
| 9 | + create_release: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + permissions: |
| 12 | + contents: write |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v3 |
| 15 | + - uses: ncipollo/release-action@v1 |
| 16 | + |
| 17 | + release: |
| 18 | + needs: create_release |
| 19 | + name: release ${{ matrix.target }} |
| 20 | + permissions: write-all |
| 21 | + runs-on: ubuntu-latest |
| 22 | + strategy: |
| 23 | + fail-fast: false |
| 24 | + matrix: |
| 25 | + include: |
| 26 | + - target: x86_64-pc-windows-gnu |
| 27 | + - target: x86_64-unknown-linux-musl |
| 28 | + - target: x86_64-apple-darwin |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@master |
| 31 | + - name: Compile and release |
| 32 | + uses: rust-build/rust-build.action@v1.3.2 |
| 33 | + env: |
| 34 | + SRC_DIR: forge-exec-ipc-client |
| 35 | + UPLOAD_MODE: none |
| 36 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + with: |
| 38 | + RUSTTARGET: ${{ matrix.target }} |
| 39 | + ARCHIVE_TYPES: ${{ matrix.archive }} |
| 40 | + TOOLCHAIN_VERSION: 1.64.0 |
| 41 | + - name: tar |
| 42 | + working-directory: ./forge-exec-ipc-client |
| 43 | + run: | |
| 44 | + export PARENT_FOLDER=../output |
| 45 | + export FILE_NAME=forge-exec-ipc-client${{ matrix.target == 'x86_64-pc-windows-gnu' && '.exe' || '' }} |
| 46 | + export FOLDER_NAME=forge-exec-ipc-client_${{ github.ref_name }}_${{ matrix.target }} |
| 47 | + echo $FOLDER_NAME/$FILE_NAME |
| 48 | + mkdir -p archive_folder/$FOLDER_NAME |
| 49 | + cp $PARENT_FOLDER/$FILE_NAME archive_folder/$FOLDER_NAME/ |
| 50 | + tar --directory=archive_folder -cf archive.tar.gz $FOLDER_NAME |
| 51 | + - name: upload |
| 52 | + working-directory: ./forge-exec-ipc-client |
| 53 | + run: | |
| 54 | + id=$(gh api -H "Accept: application/vnd.github+json" /repos/wighawag/forge-exec/releases/tags/${{ github.ref_name }} --jq .id) |
| 55 | + curl --fail-with-body -sS -X POST --data-binary @"archive.tar.gz" -H 'Content-Type: application/octet-stream' -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://uploads.github.com/repos/wighawag/forge-exec/releases/$id/assets?name=forge-exec-ipc-client_${{ github.ref_name }}_${{ matrix.target }}.tar.gz" |
| 56 | + env: |
| 57 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 58 | + windows-msvc-release: |
| 59 | + needs: create_release |
| 60 | + name: release windows msvc |
| 61 | + permissions: write-all |
| 62 | + runs-on: windows-latest |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@master |
| 65 | + - name: Build |
| 66 | + working-directory: ./forge-exec-ipc-client |
| 67 | + run: | |
| 68 | + cargo build --release |
| 69 | + - name: tar |
| 70 | + working-directory: ./forge-exec-ipc-client |
| 71 | + run: | |
| 72 | + mkdir archive_folder |
| 73 | + mkdir archive_folder/forge-exec-ipc-client_${{ github.ref_name }}_x86_64-pc-windows-msvc |
| 74 | + cp target/release/forge-exec-ipc-client.exe archive_folder/forge-exec-ipc-client_${{ github.ref_name }}_x86_64-pc-windows-msvc/ |
| 75 | + tar --directory=archive_folder -cf archive.tar.gz forge-exec-ipc-client_${{ github.ref_name }}_x86_64-pc-windows-msvc |
| 76 | + - name: upload |
| 77 | + working-directory: ./forge-exec-ipc-client |
| 78 | + run: | |
| 79 | + $id = gh api -H "Accept: application/vnd.github+json" /repos/wighawag/forge-exec/releases/tags/${{ github.ref_name }} --jq .id |
| 80 | + curl --fail-with-body -sS -X POST --data-binary "@archive.tar.gz" -H 'Content-Type: application/octet-stream' -H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' "https://uploads.github.com/repos/wighawag/forge-exec/releases/$id/assets?name=forge-exec-ipc-client_${{ github.ref_name }}_x86_64-pc-windows-msvc.tar.gz" |
| 81 | + env: |
| 82 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 83 | + macos-arm-release: |
| 84 | + needs: create_release |
| 85 | + name: release mac os arm release |
| 86 | + permissions: write-all |
| 87 | + runs-on: macos-12 |
| 88 | + steps: |
| 89 | + - uses: actions/checkout@master |
| 90 | + - name: check toolchain |
| 91 | + run: rustup default |
| 92 | + - name: Build |
| 93 | + working-directory: ./forge-exec-ipc-client |
| 94 | + run: | |
| 95 | + rustup toolchain install stable-aarch64-apple-darwin |
| 96 | + rustup target add aarch64-apple-darwin |
| 97 | + cargo build --release --target aarch64-apple-darwin |
| 98 | + - name: tar |
| 99 | + working-directory: ./forge-exec-ipc-client |
| 100 | + run: | |
| 101 | + export PARENT_FOLDER=target/aarch64-apple-darwin/release |
| 102 | + export FILE_NAME=forge-exec-ipc-client |
| 103 | + export FOLDER_NAME=forge-exec-ipc-client_${{ github.ref_name }}_aarch64-apple-darwin |
| 104 | + echo $FOLDER_NAME/$FILE_NAME |
| 105 | + mkdir -p archive_folder/$FOLDER_NAME |
| 106 | + cp $PARENT_FOLDER/$FILE_NAME archive_folder/$FOLDER_NAME/ |
| 107 | + tar --directory=archive_folder -cf archive.tar.gz $FOLDER_NAME |
| 108 | + - name: upload |
| 109 | + working-directory: ./forge-exec-ipc-client |
| 110 | + run: | |
| 111 | + id=$(gh api -H "Accept: application/vnd.github+json" /repos/wighawag/forge-exec/releases/tags/${{ github.ref_name }} --jq .id) |
| 112 | + curl --fail-with-body -sS -X POST --data-binary @"archive.tar.gz" -H 'Content-Type: application/octet-stream' -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://uploads.github.com/repos/wighawag/forge-exec/releases/$id/assets?name=forge-exec-ipc-client_${{ github.ref_name }}_aarch64-apple-darwin.tar.gz" |
| 113 | + env: |
| 114 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 115 | + |
| 116 | + npm_publish: |
| 117 | + name: publish to npm |
| 118 | + needs: [release, windows-msvc-release, macos-arm-release] |
| 119 | + runs-on: ubuntu-latest |
| 120 | + steps: |
| 121 | + - uses: actions/checkout@v3 |
| 122 | + - uses: actions/setup-node@v3 |
| 123 | + with: |
| 124 | + node-version: 18 |
| 125 | + - name: download the binaries from the release |
| 126 | + run: | |
| 127 | + curl -L -O https://uploads.github.com/repos/wighawag/forge-exec/releases/$id/assets?name=forge-exec-ipc-client_${{ github.ref_name }}_aarch64-apple-darwin.tar.gz |
| 128 | + curl -L -O https://uploads.github.com/repos/wighawag/forge-exec/releases/$id/assets?name=forge-exec-ipc-client_${{ github.ref_name }}_x86_64-apple-darwin.tar.gz |
| 129 | + curl -L -O https://uploads.github.com/repos/wighawag/forge-exec/releases/$id/assets?name=forge-exec-ipc-client_${{ github.ref_name }}_x86_64-pc-windows-gnu.tar.gz |
| 130 | + curl -L -O https://uploads.github.com/repos/wighawag/forge-exec/releases/$id/assets?name=forge-exec-ipc-client_${{ github.ref_name }}_x86_64-pc-windows-msvc.tar.gz |
| 131 | + curl -L -O https://uploads.github.com/repos/wighawag/forge-exec/releases/$id/assets?name=forge-exec-ipc-client_${{ github.ref_name }}_x86_64-unknown-linux-musl.tar.gz |
| 132 | + - name: extract them in the bin folder |
| 133 | + run: | |
| 134 | + TARGET=aarch64-apple-darwin mkdir bin/$TARGET; tar -xf forge-exec-ipc-client_${{ github.ref_name }}_$TARGET.tar.gz --strip=1 -C bin/$TARGET |
| 135 | + TARGET=x86_64-apple-darwin mkdir bin/$TARGET; tar -xf forge-exec-ipc-client_${{ github.ref_name }}_$TARGET.tar.gz --strip=1 -C bin/$TARGET |
| 136 | + TARGET=x86_64-pc-windows-gnu mkdir bin/$TARGET; tar -xf forge-exec-ipc-client_${{ github.ref_name }}_$TARGET.tar.gz --strip=1 -C bin/$TARGET |
| 137 | + TARGET=x86_64-pc-windows-msvc mkdir bin/$TARGET; tar -xf forge-exec-ipc-client_${{ github.ref_name }}_$TARGET.tar.gz --strip=1 -C bin/$TARGET |
| 138 | + TARGET=x86_64-unknown-linux-musl mkdir bin/$TARGET; tar -xf forge-exec-ipc-client_${{ github.ref_name }}_$TARGET.tar.gz --strip=1 -C bin/$TARGET |
| 139 | + - name: prepare package.json |
| 140 | + run: V_REF=${{ github.ref_name }};VERSION=${V_REF:1};sed -i "s/__VERSION__/$VERSION/" package.json |
| 141 | + - name: tree |
| 142 | + run: | |
| 143 | + sudo apt-get install -y tree |
| 144 | + tree |
| 145 | + # - uses: JS-DevTools/npm-publish@v2 |
| 146 | + # with: |
| 147 | + # token: ${{ secrets.NPM_AUTH_TOKEN }} |
| 148 | + |
| 149 | + |
| 150 | + |
| 151 | + |
0 commit comments