From 5762f8eabbefc584262fa703a711a583df6d335e Mon Sep 17 00:00:00 2001 From: Felix Deimel Date: Fri, 17 May 2024 12:03:34 +0200 Subject: [PATCH] CI script --- .github/workflows/build.yml | 88 +++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..238acee --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,88 @@ +name: Build +on: + push: + tags: + - '1.*.*' + paths-ignore: + - '.github/workflows/x-*.yml' + workflow_dispatch: # manually-triggered runs + +permissions: + # allowed to create releases (ref. https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs) + contents: write + +concurrency: + # cancel pending runs when a PR gets updated (ref. https://github.com/rust-lang/rust/blob/75fd074338801fba74a8cf7f8c48c5c5be362d08/.github/workflows/ci.yml#L35) + group: ${{ github.head_ref || github.run_id }}-${{ github.actor }} + cancel-in-progress: true + +defaults: + run: + shell: bash + +jobs: + build: + name: Build + runs-on: macos-14 + + env: # use tag version, if available, falling back to 1.21.2 (stable) + MITKERBEROS_VERSION: "${{ startsWith(github.ref, 'refs/tags/1.') && github.ref_name || '1.21.2' }}" + PUBLISH_RELEASE: "${{ startsWith(github.ref, 'refs/tags/1.') && '1' || '0' }}" + + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: restore cache + id: cache-mitkerberos-src + uses: actions/cache/restore@v4 + with: + key: "mitkerberos-src-${{ env.MITKERBEROS_VERSION }}" + path: | + build/mitkerberos-${{ env.MITKERBEROS_VERSION }}.tar.gz + + - name: build + run: scripts/build.sh + + - name: save cache + if: "steps.cache-mitkerberos-src.outputs.cache-hit != 'true'" + uses: actions/cache/save@v4 + with: + key: "${{ steps.cache-mitkerberos-src.outputs.cache-primary-key }}" + path: | + build/mitkerberos-${{ env.MITKERBEROS_VERSION }}.tar.gz + + - name: publish native libraries + uses: actions/upload-artifact@v4 + with: + name: "mitkerberos-${{ env.MITKERBEROS_VERSION }}" + retention-days: 5 + if-no-files-found: "error" + path: | + build/mitkerberos-${{ env.MITKERBEROS_VERSION }}/macosx/** + + - name: publish xcframework + uses: actions/upload-artifact@v4 + with: + name: "mitkerberos-${{ env.MITKERBEROS_VERSION }}.xcframework" + retention-days: 5 + if-no-files-found: "error" + path: | + build/mitkerberos-${{ env.MITKERBEROS_VERSION }}/MITKerberos.xcframework + + - name: pack release artifacts + if: "success() && env.PUBLISH_RELEASE == '1'" + run: scripts/release.sh + + - name: create release + if: "success() && env.PUBLISH_RELEASE == '1'" + uses: softprops/action-gh-release@v2 + with: + name: "${{ env.MITKERBEROS_VERSION }}" + draft: true + prerelease: false + generate_release_notes: false + fail_on_unmatched_files: true + files: | + build/mitkerberos-${{ env.MITKERBEROS_VERSION }}/mitkerberos.tar.gz + build/mitkerberos-${{ env.MITKERBEROS_VERSION }}/MITKerberos.xcframework.tar.gz