Merge pull request #148 from samuele-cozzi/release-please--branches--… #175
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
on: | |
push: | |
branches: | |
- main | |
env: | |
PLUGIN_NAME: obsidian-marp-slides | |
name: release | |
jobs: | |
release-please: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: google-github-actions/release-please-action@v3 | |
id: release | |
with: | |
token: ${{ secrets.PAT }} | |
release-type: node | |
package-name: release-please-action | |
config-file: release-please-config.json | |
include-v-in-tag: false | |
changelog-path: docs/CHANGELOG.md | |
outputs: | |
release_created: ${{ steps.release.outputs.release_created }} | |
tag_name: ${{ steps.release.outputs.tag_name }} | |
upload_url: ${{ steps.release.outputs.upload_url }} | |
release-plugin: | |
needs: release-please | |
runs-on: ubuntu-latest | |
if: ${{ needs.release-please.outputs.release_created }} | |
steps: | |
- uses: actions/checkout@v2 | |
# these if statements ensure that a publication only occurs when | |
# a new release is created: | |
with: | |
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token | |
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo | |
token: ${{secrets.PAT}} # use a personal acces token so that other actions can trigger | |
ref: main | |
# update the manifest.json with the tag version | |
- name: Update manifest version | |
uses: jossef/action-set-json-field@v1 | |
with: | |
file: manifest.json | |
field: version | |
value: ${{ needs.release-please.outputs.tag_name }} | |
- name: Commit manifest | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git branch --show-current | |
git add manifest.json | |
git status | |
git commit -m updateVersion | |
git pull | |
# push the commit | |
- name: Push changes | |
uses: ad-m/[email protected] | |
with: | |
github_token: ${{secrets.GITHUB_TOKEN}} | |
branch: main | |
- name: Build | |
id: build | |
run: | | |
npm install | |
npm run build | |
mkdir ${{ env.PLUGIN_NAME }} | |
cp main.js manifest.json styles.css ${{ env.PLUGIN_NAME }} | |
zip -r ${{ env.PLUGIN_NAME }}.zip ${{ env.PLUGIN_NAME }} | |
ls | |
echo "::set-output name=tag_name::$(git tag --sort version:refname | tail -n 1)" | |
- name: Test & publish code coverage | |
uses: paambaati/[email protected] | |
env: | |
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}} | |
with: | |
coverageCommand: npm run test | |
coverageLocations: | | |
${{github.workspace}}/tests/coverage/lcov.info:lcov | |
- name: Upload zip file | |
id: upload-zip | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.release-please.outputs.upload_url }} | |
asset_path: ./${{ env.PLUGIN_NAME }}.zip | |
asset_name: ${{ env.PLUGIN_NAME }}-${{ needs.release-please.outputs.tag_name }}.zip | |
asset_content_type: application/zip | |
- name: Upload main.js | |
id: upload-main | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.release-please.outputs.upload_url }} | |
asset_path: ./main.js | |
asset_name: main.js | |
asset_content_type: text/javascript | |
- name: Upload manifest.json | |
id: upload-manifest | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.release-please.outputs.upload_url }} | |
asset_path: ./manifest.json | |
asset_name: manifest.json | |
asset_content_type: application/json | |
- name: Upload styles.css | |
id: upload-css | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.release-please.outputs.upload_url }} | |
asset_path: ./styles.css | |
asset_name: styles.css | |
asset_content_type: text/css |