|
| 1 | +name: Build obsidian plugin |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + # Sequence of patterns matched against refs/tags |
| 6 | + tags: |
| 7 | + - '*' # Push events to matching any tag format, i.e. 1.0, 20.15.10 |
| 8 | + |
| 9 | +env: |
| 10 | + PLUGIN_NAME: cm-editor-syntax-highlight-obsidian # Change this to the name of your plugin-id folder |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v2 |
| 19 | + - name: Use Node.js |
| 20 | + uses: actions/setup-node@v1 |
| 21 | + with: |
| 22 | + node-version: '14.x' # You might need to adjust this value to your own version |
| 23 | + - name: Build |
| 24 | + id: build |
| 25 | + run: | |
| 26 | + npm install |
| 27 | + npm run build --if-present |
| 28 | + mkdir ${{ env.PLUGIN_NAME }} |
| 29 | + cp main.js manifest.json styles.css README.md ${{ env.PLUGIN_NAME }} |
| 30 | + zip -r ${{ env.PLUGIN_NAME }}.zip ${{ env.PLUGIN_NAME }} |
| 31 | + ls |
| 32 | + echo "::set-output name=tag_name::$(git tag --sort version:refname | tail -n 1)" |
| 33 | + - name: Create Release |
| 34 | + id: create_release |
| 35 | + uses: actions/create-release@v1 |
| 36 | + env: |
| 37 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 38 | + VERSION: ${{ github.ref }} |
| 39 | + with: |
| 40 | + tag_name: ${{ github.ref }} |
| 41 | + release_name: ${{ github.ref }} |
| 42 | + draft: false |
| 43 | + prerelease: false |
| 44 | + - name: Upload zip file |
| 45 | + id: upload-zip |
| 46 | + uses: actions/upload-release-asset@v1 |
| 47 | + env: |
| 48 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 49 | + with: |
| 50 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 51 | + asset_path: ./${{ env.PLUGIN_NAME }}.zip |
| 52 | + asset_name: ${{ env.PLUGIN_NAME }}-${{ steps.build.outputs.tag_name }}.zip |
| 53 | + asset_content_type: application/zip |
| 54 | + - name: Upload main.js |
| 55 | + id: upload-main |
| 56 | + uses: actions/upload-release-asset@v1 |
| 57 | + env: |
| 58 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 59 | + with: |
| 60 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 61 | + asset_path: ./main.js |
| 62 | + asset_name: main.js |
| 63 | + asset_content_type: text/javascript |
| 64 | + - name: Upload manifest.json |
| 65 | + id: upload-manifest |
| 66 | + uses: actions/upload-release-asset@v1 |
| 67 | + env: |
| 68 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 69 | + with: |
| 70 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 71 | + asset_path: ./manifest.json |
| 72 | + asset_name: manifest.json |
| 73 | + asset_content_type: application/json |
| 74 | + - name: Upload styles.css |
| 75 | + id: upload-css |
| 76 | + uses: actions/upload-release-asset@v1 |
| 77 | + env: |
| 78 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 79 | + with: |
| 80 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 81 | + asset_path: ./styles.css |
| 82 | + asset_name: styles.css |
| 83 | + asset_content_type: text/css |
0 commit comments