diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml new file mode 100644 index 00000000..4e4b6656 --- /dev/null +++ b/.github/workflows/actions.yaml @@ -0,0 +1,79 @@ +name: Release +on: workflow_dispatch +jobs: + prepare-release: + runs-on: ubuntu-latest + outputs: + sha: ${{ steps.commit.outputs.sha }} + steps: + - uses: actions/checkout@v4 + name: Fetch entire history (for conventional commits) + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + - name: Configure Git + run: | + git config --global user.name GitHub Actions + git config user.email github-actions@github.com + - name: Install Knope + uses: knope-dev/action@v2.0.0 + with: + version: 0.11.0 + - run: knope prepare-release --verbose + name: Update versioned files and changelog + - name: Store commit + id: commit + run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + + build-artifacts: + needs: prepare-release + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.prepare-release.outputs.sha }} + - uses: Homebrew/actions/setup-homebrew@master + - uses: ningenMe/setup-rustup@v1.1.0 + - name: Install Make + run: brew install make + - name: Build Setup + run: make mac-setup + - name: Build Artifacts + run: make all + - name: Upload Artifact + uses: actions/upload-artifact@v4.0.0 + with: + name: dotlottie-player.android.tar.gz + path: release/android/dotlottie-player.android.tar.gz + if-no-files-found: error + - name: Upload Artifact + uses: actions/upload-artifact@v4.0.0 + with: + name: dotlottie-player.darwin.tar.gz + path: release/darwin/dotlottie-player.darwin.tar.gz + if-no-files-found: error + - name: Upload Artifact + uses: actions/upload-artifact@v4.0.0 + with: + name: dotlottie-player.wasm.tar.gz + path: release/wasm/dotlottie-player.wasm.tar.gz + if-no-files-found: error + + release: + needs: [build-artifacts, prepare-release] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.prepare-release.outputs.sha }} + - uses: actions/download-artifact@v4.1.0 + with: + path: release + merge-multiple: true + - name: Install Knope + uses: knope-dev/action@v2.0.0 + with: + version: 0.11.0 + - run: knope release --verbose + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Makefile b/Makefile index c4e04b91..613390af 100644 --- a/Makefile +++ b/Makefile @@ -61,6 +61,7 @@ STRIP := $(ANDROID_NDK_HOME)/toolchains/llvm/prebuilt/$(ANDROID_BUILD_PLATFORM)/ # Apple APPLE := apple +DARWIN := darwin APPLE_BUILD := $(BUILD)/$(APPLE) APPLE_IOS := ios @@ -374,6 +375,9 @@ define ANDROID_RELEASE cp $(RUNTIME_FFI_TARGET_LIB) $(DOTLOTTIE_PLAYER_LIB_DIR)/$(DOTLOTTIE_PLAYER_LIB) cp $(RUNTIME_FFI)/$(RUNTIME_FFI_ANDROID_ASSETS)/$(ANDROID)/* $(DOTLOTTIE_PLAYER_ANDROID_RELEASE_DIR) echo "dlplayer-version=$(CRATE_VERSION)-$(COMMIT_HASH)" > $(DOTLOTTIE_PLAYER_ANDROID_RELEASE_DIR)/$(DOTLOTTIE_PLAYER_GRADLE_PROPERTIES) + cd $(RELEASE)/$(ANDROID) && \ + rm -f $(DOTLOTTIE_PLAYER).$(ANDROID).tar.gz && \ + tar zcf $(DOTLOTTIE_PLAYER).$(ANDROID).tar.gz * endef define LIPO_CREATE @@ -414,6 +418,9 @@ define APPLE_RELEASE $$(find $(RUNTIME_FFI)/$(APPLE_BUILD) -type d -depth 2 | sed 's/^/-framework /' | tr '\n' ' ') \ -output $(RELEASE)/$(APPLE)/$(DOTLOTTIE_PLAYER_XCFRAMEWORK) cp $(RUNTIME_FFI)/$(RUNTIME_FFI_UNIFFI_BINDINGS)/$(SWIFT)/$(DOTLOTTIE_PLAYER_SWIFT) $(RELEASE)/$(APPLE)/. + cd $(RELEASE)/$(APPLE) && \ + rm -f $(DOTLOTTIE_PLAYER).$(DARWIN).tar.gz && \ + tar zcf $(DOTLOTTIE_PLAYER).$(DARWIN).tar.gz * endef define WASM_RELEASE @@ -422,6 +429,9 @@ define WASM_RELEASE cp $(RUNTIME_FFI)/$(WASM_BUILD)/$(BUILD)/$(WASM_MODULE).wasm \ $(RUNTIME_FFI)/$(WASM_BUILD)/$(BUILD)/$(WASM_MODULE).js \ $(RELEASE)/$(WASM) + cd $(RELEASE)/$(WASM) && \ + rm -f $(DOTLOTTIE_PLAYER).$(WASM).tar.gz && \ + tar zcf $(DOTLOTTIE_PLAYER).$(WASM).tar.gz * endef # $1: rust target triple, e.g. aarch64-linux-android diff --git a/knope.toml b/knope.toml new file mode 100644 index 00000000..05ec080e --- /dev/null +++ b/knope.toml @@ -0,0 +1,43 @@ +[github] +owner = 'LottieFiles' +repo = 'dotlottie-rs' + +[package] +versioned_files = ["dotlottie-ffi/Cargo.toml"] + +[[package.assets]] +path = "release/dotlottie-player.darwin.tar.gz" +name = "dotlottie-player.darwin.tar.gz" + +[[package.assets]] +path = "release/dotlottie-player.android.tar.gz" +name = "dotlottie-player.android.tar.gz" + +[[package.assets]] +path = "release/dotlottie-player.wasm.tar.gz" +name = "dotlottie-player.wasm.tar.gz" + +[[workflows]] +name = "prepare-release" + +[[workflows.steps]] +type = "PrepareRelease" + +[[workflows.steps]] +type = "Command" +command = "git commit -m \"chore: prepare release $version\" && git push" + +[workflows.steps.variables] +"$version" = "Version" + +[[workflows]] +name = "release" + +[[workflows.steps]] +type = "Release" + +[[workflows]] +name = "document-change" + +[[workflows.steps]] +type = "CreateChangeFile"