2020-05-14 00:47:15 +02:00
on :
repository_dispatch :
types : publish
jobs :
update_changelog_and_sync_package_lock_version :
name : Update CHANGELOG.md and make sure package.json and package-lock.json versions matches.
runs-on : ubuntu-latest
steps :
- name : Synchronize package.json and package-lock.json version if needed.
2021-02-26 21:32:19 +01:00
uses : garronej/github_actions_toolkit@v1.11
2020-05-14 00:47:15 +02:00
env :
GITHUB_TOKEN : ${{ secrets.PAT }}
with :
action_name : sync_package_and_package_lock_version
owner : ${{github.repository_owner}}
repo : ${{github.event.client_payload.repo}}
2020-08-18 16:45:15 +02:00
branch : develop
2020-05-14 00:47:15 +02:00
commit_author_email : ts_ci@github.com
- name : Update CHANGELOG.md
if : ${{ !!github.event.client_payload.from_version }}
2021-02-26 21:32:19 +01:00
uses : garronej/github_actions_toolkit@v1.11
2020-05-14 00:47:15 +02:00
env :
GITHUB_TOKEN : ${{ secrets.PAT }}
with :
action_name : update_changelog
owner : ${{github.repository_owner}}
repo : ${{github.event.client_payload.repo}}
branch_behind : latest
2020-08-18 16:45:15 +02:00
branch_ahead : develop
2020-05-14 00:47:15 +02:00
commit_author_email : ts_ci@github.com
exclude_commit_from_author_names_json : '["ts_ci"]'
2020-08-18 16:45:15 +02:00
publish :
2020-05-14 00:47:15 +02:00
runs-on : ubuntu-latest
needs : update_changelog_and_sync_package_lock_version
steps :
2020-05-14 02:15:58 +02:00
- uses : actions/checkout@v2
2020-05-17 00:09:21 +02:00
with :
fetch-depth : 0
2020-08-18 16:45:15 +02:00
ref : develop
2020-05-20 05:39:37 +02:00
- name : Remove .github directory, useless on 'latest' branch
run : rm -r .github
2020-05-14 00:47:15 +02:00
- name : Remove branch 'latest'
continue-on-error : true
2020-05-16 23:09:30 +02:00
run : |
git branch -d latest || true
git push origin :latest
2020-05-14 00:47:15 +02:00
- name : Create the new 'latest' branch
run : |
git branch latest
git checkout latest
- uses : actions/setup-node@v1
2021-02-26 21:32:19 +01:00
- run : |
if [ -f "./yarn.lock" ]; then
yarn install --frozen-lockfile
else
npm ci
fi
- run : |
PACKAGE_MANAGER=npm
if [ -f "./yarn.lock" ]; then
PACKAGE_MANAGER=yarn
fi
$PACKAGE_MANAGER run enable_short_import_path
2020-05-14 00:47:15 +02:00
env :
DRY_RUN : "0"
- name : (DEBUG) Show how the files have been moved to enable short import
run : ls -lR
- name : Publishing on NPM
run : |
2020-08-18 16:45:15 +02:00
if [ "$(npm show . version)" = "$VERSION" ]; then
echo "This version is already published"
exit 0
fi
2020-05-14 02:47:14 +02:00
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"
2020-05-14 00:47:15 +02:00
false
fi
2020-05-14 04:16:52 +02:00
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > .npmrc
2020-05-14 00:47:15 +02:00
npm publish
2020-05-14 04:16:52 +02:00
rm .npmrc
env :
NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
2020-08-18 16:45:15 +02:00
VERSION : ${{ github.event.client_payload.to_version }}
2020-05-14 00:47:15 +02:00
- name : Commit changes
run : |
git config --local user.email "ts_ci@github.com"
git config --local user.name "ts_ci"
git add -A
2020-08-18 16:45:15 +02:00
git commit -am "Enabling shorter import paths [automatic]"
2020-05-26 14:11:31 +02:00
- run : git push origin latest
2020-05-23 08:05:41 +02:00
- name : Release body
id : id_rb
run : |
if [ "$FROM_VERSION" = "" ]; then
echo "::set-output name=body::🚀"
else
echo "::set-output name=body::📋 [CHANGELOG](https://github.com/$OWNER/$REPO/blob/$REF/CHANGELOG.md)"
fi
env :
FROM_VERSION : ${{ github.event.client_payload.from_version }}
OWNER : ${{github.repository_owner}}
REPO : ${{github.event.client_payload.repo}}
2020-08-18 16:45:15 +02:00
REF : v${{github.event.client_payload.to_version}}
2020-05-14 00:47:15 +02:00
- name : Create Release
uses : garronej/create-release@master
env :
GITHUB_TOKEN : ${{ secrets.PAT }}
with :
2020-08-18 16:45:15 +02:00
tag_name : v${{ github.event.client_payload.to_version }}
release_name : Release v${{ github.event.client_payload.to_version }}
2020-05-14 00:47:15 +02:00
branch : latest
draft : false
prerelease : false
2021-02-26 21:32:19 +01:00
body : ${{ steps.id_rb.outputs.body }}