Change to actions4git/add-commit-push #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | ||
on: | ||
on: | ||
release: ['published'] | ||
jobs: | ||
build: | ||
name: Build release artifacts | ||
permissions: | ||
contents: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Use Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: '3.0' | ||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
registry-url: https://registry.npmjs.org/ | ||
- name: Install Ruby dependencies | ||
run: bundle install | ||
- name: Install Node dependencies | ||
run: npm ci | ||
- name: Build JavaScript library | ||
run: npm run build | ||
- name: Build distributable Ruby library | ||
run: bundle exec rake build_dist | ||
- name: Build sample SketchUp extension | ||
run: bundle exec rake build_sample_extension | ||
- name: Build tutorial SketchUp extension | ||
run: bundle exec rake build_tutorial_rbz | ||
- name: Include built files in repository | ||
uses: actions4git/add-commit-push@v1 | ||
with: | ||
commit-message: "[AUTO] Update sample files" | ||
- name: Add tutorial SketchUp extension to release | ||
uses: actions/github-script@v7 | ||
env: | ||
path: ae_bridgelibrary*.rbz | ||
with: | ||
script: | | ||
// From https://til.simonwillison.net/github-actions/attach-generated-file-to-release | ||
const fs = require('fs') | ||
const path = require('path') | ||
// Resolve any wildcards with glob (by default included from @actions/glob) | ||
const globber = await glob.create(process.env.path) | ||
const assetPath = (await globber.glob())[0] | ||
// Get release for this tag | ||
const tag = context.ref.replace('refs/tags/', '') | ||
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) | ||
}) | ||
publish-npm: | ||
name: Publish JavaScript library on NPM | ||
# We could specify `needs: build` and publish the compiled code (as in <=3.0.7) | ||
# but the source is more useful for development and optimization of other SketchUp plugins. | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: npm ci | ||
- run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.npm_token}} |