From fe02f362e9c005d74d71842ddc9f3972e973bd2a Mon Sep 17 00:00:00 2001 From: v-rocheleau Date: Tue, 17 Sep 2024 13:39:47 -0400 Subject: [PATCH] chore: release gh actions workflow test --- .github/workflows/build.yml | 14 --------- .github/workflows/release.yml | 59 +++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bd9b7f9f3..b2c9bf1ae 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,17 +33,3 @@ jobs: image-name: ghcr.io/bento-platform/katsu development-dockerfile: bento.dev.Dockerfile dockerfile: bento.Dockerfile - - # TODO: test, maybe just add to a protected build directory? - - name: Make release artifacts - run: | - mkdir -p ./dist/schemas - ./manage.py schema phenopacket >> ./dist/schemas/phenopacket_schema.json - ./manage.py schema experiment >> ./dist/schemas/experiment_schema.json - ./manage.py schema discovery >> ./dist/schemas/discovery.json - - - name: Upload release artifacts - uses: actions/upload-artifact@v4 - with: - name: JSON-schemas - path: ./dist/schemas diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..d15d0f1f6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,59 @@ +name: Create and upload release artifacts +on: + release: + types: [published, prereleased] + # temporary PR trigger for test + pull_request: + branches: + - develop + - 'features/**' + +jobs: + release-artifacts: + runs-on: ubuntu-latest + + permissions: + contents: read + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + - name: Install Poetry + run: python -m pip install poetry + - name: Install dependencies + run: poetry install + - name: Make release artifacts + run: | + mkdir -p ./dist/schemas + ./manage.py schema phenopacket >> ./dist/schemas/phenopacket_schema.json + ./manage.py schema experiment >> ./dist/schemas/experiment_schema.json + ./manage.py schema discovery >> ./dist/schemas/discovery.json + - name: Upload release artifacts + uses: actions/github-scripts@v7 + with: + script: | + const fs = require(fs); + + # temporary hardcoding for test + const tag = "v8.0.2-test" + # const tag = context.ref.replace("refs/tags/", ""); + console.log("tag = ", tag); + + const release = await github.rest.repos.getReleaseByTag({ + owner: context.repo.owner, + repo: context.repo.repo, + tag + }); + await github.rest.repos.uploadReleaseAsset({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: release.data.id, + name: "JSON Schemas", + data: await fs.readdirSync("./dist/schemas") + });