From ad4467dc0c98ba6880e2b0c1f84af2c335199fee Mon Sep 17 00:00:00 2001 From: Aerilius Date: Sun, 28 Apr 2024 20:09:13 +0200 Subject: [PATCH] Add GitHub release action --- .github/workflows/release.yml | 78 +++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..72e199f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,78 @@ +name: Release SketchUp extension + +on: + push +# release: +# types: +# - created + +jobs: + build_javascript: + name: Build JavaScript library + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Use Node.js + uses: actions/setup-node@v4 + - name: Install dependencies + run: npm install + - name: Build JavaScript library + run: npm run build + - name: Archive production artifacts + uses: actions/upload-artifact@v4 + with: + name: js-lib + path: src/ae_attribute_inspector/js/main.js + + build_sketchup_extension: + name: Build SketchUp extension rbz package + runs-on: ubuntu-latest + needs: build_javascript + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Use Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.0' + - name: Install dependencies + run: bundle install + - name: Download a single artifact + uses: actions/download-artifact@v4 + with: + name: js-lib + path: src/ae_attribute_inspector/js/main.js + - name: Build package + run: bundle exec rake build_rbz +# - name: Archive production artifacts +# uses: actions/upload-artifact@v4 +# with: +# path: ae_attribute_inspector*.rbz + - name: Add package to release + uses: actions/github-script@v7 + with: + path: ae_attribute_inspector*.rbz + script: | + // From https://til.simonwillison.net/github-actions/attach-generated-file-to-release + const fs = require('fs'); + const path = require('path'); + const tag = context.ref.replace('refs/tags/', ''); + // Resolve any wildcards with glob (by default included from @actions/glob) + const globber = await glob.create(core.getInput('path', { required: true })) + const assetPath = await globber.glob()[0] + console.log(path.basename(assetPath)) + // Get release for this tag + const release = await github.repos.getReleaseByTag({ + owner: context.repo.owner, + repo: context.repo.repo, + tag + }); + // Upload the release asset + await github.repos.uploadReleaseAsset({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: release.data.id, + name: path.basename(assetPath), + data: await fs.readFileSync(assetPath) + });