From eb9eb2b3aff402761d984096a8a48ada41bd1195 Mon Sep 17 00:00:00 2001 From: Andres Almiray Date: Tue, 7 Jan 2025 19:47:27 +0100 Subject: [PATCH] build: Add GitHub workflow --- .github/workflows/early-access.yml | 70 ++++++++++++++++++++++++ .github/workflows/release.yml | 79 +++++++++++++++++++++++++++ .github/workflows/reusable-build.yml | 51 +++++++++++++++++ .gitignore | 3 + README.adoc | 1 - jreleaser.yml | 4 +- src/helloworld.cmi | Bin 193 -> 0 bytes src/helloworld.cmx | Bin 201 -> 0 bytes src/helloworld.o | Bin 1512 -> 0 bytes 9 files changed, 205 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/early-access.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/reusable-build.yml delete mode 100644 src/helloworld.cmi delete mode 100644 src/helloworld.cmx delete mode 100644 src/helloworld.o diff --git a/.github/workflows/early-access.yml b/.github/workflows/early-access.yml new file mode 100644 index 0000000..af888ad --- /dev/null +++ b/.github/workflows/early-access.yml @@ -0,0 +1,70 @@ +name: EarlyAccess + +on: + push: + branches: [ main ] + +jobs: + precheck: + if: github.repository == 'jreleaser/helloworld-ocaml' && startsWith(github.event.head_commit.message, 'Releasing version') != true + runs-on: ubuntu-latest + outputs: + VERSION: ${{ steps.vars.outputs.VERSION }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Cancel previous run + uses: styfle/cancel-workflow-action@0.12.1 + with: + access_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Version + id: vars + shell: bash + run: | + VERSION=$(cat VERSION) + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + + build: + needs: [ precheck ] + if: endsWith(${{ needs.precheck.outputs.VERSION }}, '-SNAPSHOT') + uses: jreleaser/helloworld-ocaml/.github/workflows/reusable-build.yml@main + with: + version: ${{ needs.precheck.outputs.VERSION }} + + release: + needs: [ precheck, build ] + if: endsWith(${{ needs.precheck.outputs.VERSION }}, '-SNAPSHOT') + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + pattern: artifact-* + merge-multiple: true + path: out/jreleaser/assemble/helloworld/archive + + - name: Release + uses: jreleaser/release-action@v2 + with: + arguments: release + env: + JRELEASER_PROJECT_VERSION: ${{ needs.precheck.outputs.VERSION }} + JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: JReleaser output + if: always() + uses: actions/upload-artifact@v4 + with: + retention-days: 1 + name: jreleaser-release + path: | + out/jreleaser/trace.log + out/jreleaser/output.properties diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..20e26b7 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,79 @@ +name: Release + +on: + workflow_dispatch: + inputs: + version: + description: 'Release version' + required: true + +jobs: + precheck: + name: Precheck + runs-on: ubuntu-latest + outputs: + VERSION: ${{ steps.vars.outputs.VERSION }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Cancel previous run + uses: styfle/cancel-workflow-action@0.12.1 + with: + access_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Version + id: vars + shell: bash + run: | + echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT + + build: + needs: [ precheck ] + uses: jreleaser/helloworld-ocaml/.github/workflows/reusable-build.yml@main + with: + version: ${{ needs.precheck.outputs.VERSION }} + + release: + name: Release + needs: [ precheck, build ] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + pattern: artifact-* + merge-multiple: true + path: out/jreleaser/assemble/helloworld/archive + + - name: Commit version + run: | + echo ${{ github.event.inputs.version }} > VERSION + git add VERSION + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --global user.name "GitHub Action" + git commit -a -m "Releasing version ${{ needs.precheck.outputs.VERSION }}" + git push origin main + + - name: Release + uses: jreleaser/release-action@v2 + with: + version: early-access + arguments: release + env: + JRELEASER_PROJECT_VERSION: ${{ needs.precheck.outputs.VERSION }} + JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: JReleaser output + if: always() + uses: actions/upload-artifact@v4 + with: + name: jreleaser-release + path: | + out/jreleaser/trace.log + out/jreleaser/output.properties diff --git a/.github/workflows/reusable-build.yml b/.github/workflows/reusable-build.yml new file mode 100644 index 0000000..89abcbf --- /dev/null +++ b/.github/workflows/reusable-build.yml @@ -0,0 +1,51 @@ +name: Build + +on: + workflow_call: + inputs: + version: + required: true + type: string + +jobs: + build: + name: 'Build ${{ matrix.os }}' + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, macos-13] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup OCaml + uses: ocaml/setup-ocaml@v3 + with: + ocaml-compiler: 5 + + - name: Assemble + uses: jreleaser/release-action@v2 + with: + version: early-access + arguments: assemble --select-current-platform + env: + JRELEASER_PROJECT_VERSION: ${{ inputs.version }} + JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: JReleaser output + if: always() + uses: actions/upload-artifact@v4 + with: + name: jreleaser-assemble-${{ runner.os }}-${{ runner.arch }} + path: | + out/jreleaser/trace.log + out/jreleaser/output.properties + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + retention-days: 1 + name: artifact-${{ runner.os }}-${{ runner.arch }} + path: | + out/jreleaser/assemble/helloworld/archive/*.zip diff --git a/.gitignore b/.gitignore index 90de6fc..bf2639b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ target/ out/ +*.cmx +*.cmd +*.o diff --git a/README.adoc b/README.adoc index 3ee4cb4..ab56009 100644 --- a/README.adoc +++ b/README.adoc @@ -14,7 +14,6 @@ This repository shows how to configure link:https://github.com/features/actions[ ** osx-aarch_64 ** osx-x86_64 ** linux-x86_64 - ** windows-x86_64 * assemble zip distributions with JReleaser * create rolling early-access releases with JReleaser on every push to `main` branch diff --git a/jreleaser.yml b/jreleaser.yml index a504847..83e7dd6 100644 --- a/jreleaser.yml +++ b/jreleaser.yml @@ -7,7 +7,7 @@ matrix: - { ext: '', platform: osx-aarch_64 } - { ext: '', platform: osx-x86_64 } - { ext: '', platform: linux-x86_64 } - - { ext: '.exe', platform: windows-x86_64 } + #- { ext: '.exe', platform: windows-x86_64 } hooks: script: @@ -15,7 +15,7 @@ hooks: - run: | echo "Compiling {{ matrix.platform }}" mkdir -p target/{{ matrix.platform }} - ocamlopt -o target/{{ matrix.platform }}/helloworld{{ matrix.ext }} src/helloworld.ml + opam exec -- ocamlc -o target/{{ matrix.platform }}/helloworld{{ matrix.ext }} src/helloworld.ml verbose: true applyDefaultMatrix: true verbose: true diff --git a/src/helloworld.cmi b/src/helloworld.cmi deleted file mode 100644 index 65f7bff2e1e7ac86ddd513159995c9d9e3c3a79e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 193 zcmZ=x%*`>hw6ydzFg9tKx@;c<0|PG*GXXI>5VI}N@<`3e$uG|@%1Lp6D#!pz@B^_W z5bG^KRx!cgMP|k&u@?S2C8D#pE4}GsSg=4XxFjVfGiids(Vkycw NavUoNFPPxq003*oK}G-o diff --git a/src/helloworld.cmx b/src/helloworld.cmx deleted file mode 100644 index b77029e8697221d028be1da19775c181e6c9cca7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 201 zcmZ=x%*`>hw6u&gFg9tKx@;c<1H()pmH^^dAok~AV9;mK@<`3e$uG|@%1L2iT)@KQ zuwa2&a7ju|X3_+MqdmW@ZcDl|JlhxbvQm2a+64<(I42mq$jrDT*1~_MM0ECcr8j*H z3l>;718vI8D@iTNOU!Z0FUn0UaY`)COfH^aAdqow)+!%Wt^0S+GWUP{K( qX@zy~ytle6EGl`k!T|^-Ol)v)IKiiVzmId(hvZEm2e$3yR0aUe?N2)Z diff --git a/src/helloworld.o b/src/helloworld.o deleted file mode 100644 index 6cced42131619365028e4ef440c4bf345ed7cf93..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1512 zcma)6OKTHR6u$A*h&2f!s6}WBDuOgx3q?^OfrJuljo-O*#ym#B1LuDCJFk20xs!bU^>cSdsl;A|1-cKq zz6XoQ3E&nx{vmnsbtEU^sHs@@OCC|6JHe<3QR(`6X~d)5RoQSo?xl~$xHph4LnK5_ zGtj=}EUg&RbiKR;W(E6FPpC>o8$qI~6<8x9(Q2Vo81b@fUkYxa9{2SHi(FkiArRSK zYs0bwdgN|4-73-A>Uh9FNLH{c_xuKwkxrB)(haKlR!fHo)AvnE(j}?am3l(eA*CA8 zp7A2|I5bQfO@j|*`vCcefqgu}1q2~q-G;KjWi$z7`$VJQ|0BIxE4o=EQsu$U!He+0#kY_U-eghAEM2Ik0cz@FLg!Q&y=A>@4R(h@EpZ zw5!C^J1Wu1Br>xz$sP{pb65wM35(<_RY_%Tq>^eGzFDOf&j4|y#RVYV;aU-hcR_@C zBlEB*ci=I23ITZ_OAX3Adeb=srSPy_c0#tHY4C<&_y(9GCXx@rqu=XI=7=v#z*pgK zg>x$BNAq|m{`cZPCOkTC2Yl=}^