-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add reusable wf tag & publish for Ember.js add-ons
- Loading branch information
1 parent
0993430
commit 511ef5b
Showing
1 changed file
with
85 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# GitHub Actions documentation: | ||
# https://docs.github.com/en/actions | ||
|
||
name: Create new `git tag`, create new GitHub release and publish to NPM | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
nodejs_version: | ||
description: Version of Node.js to use. | ||
default: '12' | ||
required: false | ||
type: string | ||
|
||
secrets: | ||
npm_automation_token: | ||
description: | | ||
NPM automation token authorised to publish versions. | ||
Check the settings of your package on npm. | ||
required: true | ||
|
||
jobs: | ||
create_git_tag: | ||
name: Create new `git tag` | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
outputs: | ||
new_tag: ${{ steps.detect_then_tag.outputs.tag }} | ||
new_version: ${{ steps.detect_then_tag.outputs.current-version }} | ||
old_version: ${{ steps.detect_then_tag.outputs.previous-version }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
with: | ||
# Required to ensure git history is properly checked: | ||
# https://github.com/salsify/action-detect-and-tag-new-version/blob/v2.0.1/README.md?plain=1#L11 | ||
fetch-depth: 2 | ||
|
||
- name: Detect and tag new version | ||
id: detect_then_tag | ||
uses: salsify/action-detect-and-tag-new-version@v2 | ||
|
||
create_github_release: | ||
if: ${{ needs.create_git_tag.outputs.new_tag }} | ||
name: Create new GitHub release | ||
needs: create_git_tag | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
steps: | ||
- uses: ncipollo/release-action@v1 | ||
with: | ||
body: "\ | ||
Changelog: \ | ||
${{ github.server_url }}/${{ github.repository }}\ | ||
/compare/\ | ||
v${{ needs.create_git_tag.outputs.old_version }}...v${{ needs.create_git_tag.outputs.new_version }}\ | ||
" | ||
name: Release ${{ needs.create_git_tag.outputs.new_tag }} | ||
tag: ${{ needs.create_git_tag.outputs.new_tag }} | ||
|
||
publish_npm: | ||
if: ${{ needs.create_git_tag.outputs.new_tag }} | ||
name: Publish to NPM | ||
needs: create_git_tag | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ inputs.nodejs_version }} | ||
# Required if we want to authenticate during the `npm publish`: | ||
# https://github.com/actions/setup-node/blob/v2.4.1/action.yml#L15-L16 | ||
registry-url: https://registry.npmjs.org | ||
|
||
- name: Install Dependencies | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: Publish to NPM | ||
run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.npm_automation_token }} |