From dea97814fe086642506a7e0a5fc9bbff01d58157 Mon Sep 17 00:00:00 2001 From: Brooke Date: Sat, 8 Apr 2023 01:44:43 +0100 Subject: [PATCH] Add release workflow --- .github/workflows/release.yml | 55 +++++++++++++++++++++++++++++++++++ .gitignore | 2 ++ scripts/publish.sh | 20 +++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 scripts/publish.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..5be99fa4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,55 @@ +name: Release + +on: + push: + tags: + - "v*" + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Install Aftman + uses: ok-nick/setup-aftman@v0 + + - name: Authenticate Wally + run: | + cd packages/boolean + wally login --token ${{ secrets.WALLY_ACCESS_TOKEN }} + cd ../.. + + - name: Get latest release + id: latest-release + uses: pozetroninc/github-action-get-latest-release@master + with: + token: ${{ secrets.GITHUB_TOKEN }} + continue-on-error: true # This will error if no tags have been made yet, in which case publish.sh will fallback. + + - name: Publish changed packages + run: bash ./scripts/publish.sh ${{ steps.latest-release.outputs.tag_name }} + + - name: Build project + run: rojo build --output ReactLua.rbxm + + - name: Create GitHub Release + id: create_release + uses: ncipollo/release-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + name: Release ${{ github.ref }} + tag: ${{ github.ref }} + draft: true + + - name: Upload build artifact + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./ReactLua.rbxm + asset_name: ReactLua.rbxm + asset_content_type: application/octet-stream diff --git a/.gitignore b/.gitignore index ed12d7e9..8312ffe9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ +.DS_Store + sourcemap.json globalTypes.d.lua diff --git a/scripts/publish.sh b/scripts/publish.sh new file mode 100644 index 00000000..09f73bd8 --- /dev/null +++ b/scripts/publish.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -e + +LAST_RELEASE_TAG=${1:-$(git rev-list --max-parents=0 HEAD)} # Default to the initial commit hash if no tag is found + +# Find changed packages since the last release +CHANGED_PACKAGES=$(git diff --name-only "$LAST_RELEASE_TAG" HEAD -- packages | cut -d/ -f2 | uniq) + +for PACKAGE in $CHANGED_PACKAGES; do + PACKAGE_PATH="packages/$PACKAGE" + + if [ -d "$PACKAGE_PATH" ]; then + echo "Publishing package: $PACKAGE ($PACKAGE_PATH)" + + wally publish --project-path $PACKAGE_PATH + else + echo "Skipping: $PACKAGE_PATH does not exist" + fi +done