Update publish.yaml

This commit is contained in:
Garrone Joseph 2020-08-18 16:45:15 +02:00 committed by GitHub
parent 5d75956e0c
commit 03a90047d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,18 +8,18 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Synchronize package.json and package-lock.json version if needed. - name: Synchronize package.json and package-lock.json version if needed.
uses: garronej/github_actions_toolkit@v1.4 uses: garronej/github_actions_toolkit@v1.6
env: env:
GITHUB_TOKEN: ${{ secrets.PAT }} GITHUB_TOKEN: ${{ secrets.PAT }}
with: with:
action_name: sync_package_and_package_lock_version action_name: sync_package_and_package_lock_version
owner: ${{github.repository_owner}} owner: ${{github.repository_owner}}
repo: ${{github.event.client_payload.repo}} repo: ${{github.event.client_payload.repo}}
branch: master branch: develop
commit_author_email: ts_ci@github.com commit_author_email: ts_ci@github.com
- name: Update CHANGELOG.md - name: Update CHANGELOG.md
if: ${{ !!github.event.client_payload.from_version }} if: ${{ !!github.event.client_payload.from_version }}
uses: garronej/github_actions_toolkit@v1.4 uses: garronej/github_actions_toolkit@v1.6
env: env:
GITHUB_TOKEN: ${{ secrets.PAT }} GITHUB_TOKEN: ${{ secrets.PAT }}
with: with:
@ -27,18 +27,18 @@ jobs:
owner: ${{github.repository_owner}} owner: ${{github.repository_owner}}
repo: ${{github.event.client_payload.repo}} repo: ${{github.event.client_payload.repo}}
branch_behind: latest branch_behind: latest
branch_ahead: master branch_ahead: develop
commit_author_email: ts_ci@github.com commit_author_email: ts_ci@github.com
exclude_commit_from_author_names_json: '["ts_ci"]' exclude_commit_from_author_names_json: '["ts_ci"]'
publish_npm: publish:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: update_changelog_and_sync_package_lock_version needs: update_changelog_and_sync_package_lock_version
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
fetch-depth: 0 fetch-depth: 0
ref: master ref: develop
- name: Remove .github directory, useless on 'latest' branch - name: Remove .github directory, useless on 'latest' branch
run: rm -r .github run: rm -r .github
- name: Remove branch 'latest' - name: Remove branch 'latest'
@ -59,6 +59,10 @@ jobs:
run: ls -lR run: ls -lR
- name: Publishing on NPM - name: Publishing on NPM
run: | run: |
if [ "$(npm show . version)" = "$VERSION" ]; then
echo "This version is already published"
exit 0
fi
if [ "$NPM_TOKEN" = "" ]; then if [ "$NPM_TOKEN" = "" ]; then
echo "Can't publish on NPM, You must first create a secret called NPM_TOKEN that contains your NPM auth token. https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets" echo "Can't publish on NPM, You must first create a secret called NPM_TOKEN that contains your NPM auth token. https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets"
false false
@ -68,12 +72,13 @@ jobs:
rm .npmrc rm .npmrc
env: env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
VERSION: ${{ github.event.client_payload.to_version }}
- name: Commit changes - name: Commit changes
run: | run: |
git config --local user.email "ts_ci@github.com" git config --local user.email "ts_ci@github.com"
git config --local user.name "ts_ci" git config --local user.name "ts_ci"
git add -A git add -A
git commit -am "Enable shorter import paths [automatic]" git commit -am "Enabling shorter import paths [automatic]"
- run: git push origin latest - run: git push origin latest
- name: Release body - name: Release body
id: id_rb id: id_rb
@ -87,14 +92,14 @@ jobs:
FROM_VERSION: ${{ github.event.client_payload.from_version }} FROM_VERSION: ${{ github.event.client_payload.from_version }}
OWNER: ${{github.repository_owner}} OWNER: ${{github.repository_owner}}
REPO: ${{github.event.client_payload.repo}} REPO: ${{github.event.client_payload.repo}}
REF: ${{github.event.client_payload.to_version}} REF: v${{github.event.client_payload.to_version}}
- name: Create Release - name: Create Release
uses: garronej/create-release@master uses: garronej/create-release@master
env: env:
GITHUB_TOKEN: ${{ secrets.PAT }} GITHUB_TOKEN: ${{ secrets.PAT }}
with: with:
tag_name: ${{ github.event.client_payload.to_version }} tag_name: v${{ github.event.client_payload.to_version }}
release_name: Release ${{ github.event.client_payload.to_version }} release_name: Release v${{ github.event.client_payload.to_version }}
branch: latest branch: latest
draft: false draft: false
prerelease: false prerelease: false