diff --git a/.github/workflows/nexe-ci.yml b/.github/workflows/nexe-ci.yml index ced5a51..f57fd33 100644 --- a/.github/workflows/nexe-ci.yml +++ b/.github/workflows/nexe-ci.yml @@ -44,16 +44,46 @@ jobs: with: python-version: '3.10' - - name: Run nexe CD build - id: run_cd + #- name: Run nexe CD build + # run: | + # echo "github.ref = ${{ github.ref }}" + # ./bin/run_cd + + - name: Mock nexe CD build (Linux) + if: runner.os == 'linux' + run: | + mkdir -p dist/ + echo "LINUX BUILD" > dist/linux-build + echo "linux-x64-18.20.7" > ./NEXE_ASSET_NAME + echo "0.4.0" > ./RELEASE_TAG + + + - name: Mock nexe CD build (MacOS) + if: runner.os == 'macOS' + run: | + mkdir -p dist/ + echo "MACOS BUILD" > dist/macos-build + echo "mac-arm64-18.20.7" > ./NEXE_ASSET_NAME + echo "0.4.0" > ./RELEASE_TAG + + - name: Mock nexe CD build (Windows) + if: runner.os == 'windows' + run: | + mkdir -p dist/ + echo "WINDOWS BUILD" > dist/windows-build + echo "windows-x64-18.20.7" > ./NEXE_ASSET_NAME + echo "0.4.0" > ./RELEASE_TAG + + - name: Get nexe build info + id: build_info run: | echo "github.ref = ${{ github.ref }}" - ./bin/run_cd echo "Creating dist/ dir if it doesn't exist ..." mkdir -p dist/ - echo "Getting release_file and release_id ..." + echo "Getting release_file, release_tag, and release_id ..." release_file="$(ls dist/ | head -n 1)" - release_name="$(cat ./NEXE_ASSET_NAME)" + asset_name="$(cat ./NEXE_ASSET_NAME)" + release_tag="$(cat ./RELEASE_TAG)" release_id="$(cat ./RELEASE_ID)" echo "Getting build_occurred ..." if [ "$release_file" != "" ]; then @@ -61,13 +91,16 @@ jobs: else build_occurred="false" fi + echo "Moving build artifact to asset name ($release_file -> ./$asset_name) ..." + mv "$release_file" "./$asset_name" + echo "release_tag=$release_tag" echo "release_id=$release_id" echo "release_file=$release_file" - echo "release_name=$release_name" + echo "asset_name=$asset_name" echo "build_occurred=$build_occurred" + echo "release_tag=$release_tag" >> $GITHUB_OUTPUT echo "release_id=$release_id" >> $GITHUB_OUTPUT - echo "release_file=$release_file" >> $GITHUB_OUTPUT - echo "release_name=$release_name" >> $GITHUB_OUTPUT + echo "asset_name=$asset_name" >> $GITHUB_OUTPUT echo "build_occurred=$build_occurred" >> $GITHUB_OUTPUT env: NODE_VERSION: ${{ matrix.node_version }} @@ -77,17 +110,14 @@ jobs: # Upload artifact & asset - name: Upload build artifact uses: actions/upload-artifact@v4 - if: steps.run_cd.outputs.build_occurred == 'true' + if: steps.build_info.outputs.build_occurred == 'true' with: - name: ${{ steps.run_cd.outputs.release_name }} - path: dist/${{ steps.run_cd.outputs.release_file }} + name: ${{ steps.build_info.outputs.asset_name }} + path: ./${{ steps.build_info.outputs.asset_name }} - name: Upload Release Asset - uses: actions/upload-release-asset@v1 - if: steps.run_cd.outputs.build_occurred == 'true' && github.ref == 'refs/heads/main' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: softprops/action-gh-release@v2 + if: steps.build_info.outputs.build_occurred == 'true' && github.ref == 'refs/heads/main' with: - upload_url: https://uploads.github.com/repos/urbdyn/nexe_builds/releases/${{ steps.run_cd.outputs.release_id }}/assets{?name,label} - asset_name: ${{ steps.run_cd.outputs.release_name }} - asset_path: dist/${{ steps.run_cd.outputs.release_file }} - asset_content_type: application/octet-stream + fail_on_unmatched_files: true + tag_name: ${{ steps.build_info.outputs.release_tag }} + files: ./${{ steps.build_info.outputs.asset_name }} diff --git a/.gitignore b/.gitignore index 2b23a0c..33b693c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ # From CI/CD process +/RELEASE_TAG /RELEASE_ID /NEXE_ASSET_NAME /index.js diff --git a/README.md b/README.md index 97f1a2f..ba5f2b4 100644 --- a/README.md +++ b/README.md @@ -65,8 +65,9 @@ Enjoy 🚀 2. Environmental Variables: 1. `GITHUB_TOKEN`: Token to use for querying github and creating release if needed. [required] 3. Files created: - 1. `$repo_base/NEXE_ASSET_NAME`: Name of the nexe asset to create. (integer) - 2. `$repo_base/RELEASE_ID`: The ID of the Github Release to publish assets to. (`${targetOs}-${targetArch}-${targetNodeVersion}`) + 1. `$repo_base/NEXE_ASSET_NAME`: Name of the nexe asset to create. (`${targetOs}-${targetArch}-${targetNodeVersion}`) + 2. `$repo_base/RELEASE_TAG`: The tag of the Github Release to publish assets to. (sem-ver string) + 3. `$repo_base/RELEASE_ID`: The ID of the Github Release to publish assets to. (integer) 4. Exit codes: 1. `0`: Build not needed 2. `1`: Error occurred diff --git a/bin/check_asset b/bin/check_asset index 41b4932..c1643da 100755 --- a/bin/check_asset +++ b/bin/check_asset @@ -94,6 +94,9 @@ async function main() { console.log(`Writing existing release ID (${existingRelease.id}) to file: RELEASE_ID`); const releaseIdPath = path.join(__dirname, '../RELEASE_ID'); fs.writeFileSync(releaseIdPath, `${existingRelease.id}`); + console.log(`Writing existing release tag (${existingRelease.tag_name}) to file: RELEASE_TAG`); + const releaseTagPath = path.join(__dirname, '../RELEASE_TAG'); + fs.writeFileSync(releaseTagPath, `${existingRelease.tag_name}`); const releaseAssetsNames = existingRelease.assets.map((x) => x.name); console.log(`Existing assets for release ${packageData.version}:`, releaseAssetsNames); const existingAsset = releaseAssetsNames.includes(nexeAssetName);