From c8673363deb3cd0b91d0d5a9af2688da6e9b1a9f Mon Sep 17 00:00:00 2001 From: Nathan Smith Date: Fri, 30 Aug 2024 18:50:11 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20ci:=20#14=20Add=20build=20and=20?= =?UTF-8?q?release=20actions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Overwrites the old release action which had never been run Closes: #14 --- .github/workflows/build.yml | 21 ++++++++ .github/workflows/release.yml | 95 +++++++---------------------------- 2 files changed, 39 insertions(+), 77 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..b5f33cf --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,21 @@ +name: Build +on: + - workflow_call + - workflow_dispatch +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + - name: Build + run: | + npm install + npm run build + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: dist + path: | + main.js + manifest.json diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9255f98..1b89a29 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,88 +1,29 @@ -name: Release Obsidian plugin - +name: Draft Release on: push: tags: - "*" - -env: - PLUGIN_NAME: obsidian-reading-time # Change this to match the id of your plugin. - jobs: build: + uses: "./.github/workflows/build.yml" + draft: + needs: build runs-on: ubuntu-latest - + permissions: + contents: write steps: - - uses: actions/checkout@v2 - - name: Use Node.js - uses: actions/setup-node@v1 - with: - node-version: "14.x" - - - name: Build - id: build - run: | - npm install - npm run build - mkdir ${{ env.PLUGIN_NAME }} - # cp main.js manifest.json styles.css ${{ env.PLUGIN_NAME }} - cp main.js manifest.json ${{ 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: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - VERSION: ${{ github.ref }} + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + - uses: actions/download-artifact@v4 with: - tag_name: ${{ github.ref }} - release_name: ${{ github.ref }} - draft: false - prerelease: false - - - name: Upload zip file - id: upload-zip - uses: actions/upload-release-asset@v1 + merge-multiple: true + - name: Create Draft env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./${{ env.PLUGIN_NAME }}.zip - asset_name: ${{ env.PLUGIN_NAME }}-${{ steps.build.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: ${{ steps.create_release.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: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./manifest.json - asset_name: manifest.json - asset_content_type: application/json + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + run: | + tag="${GITHUB_REF#refs/tags/}" - # - name: Upload styles.css - # id: upload-css - # uses: actions/upload-release-asset@v1 - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # with: - # upload_url: ${{ steps.create_release.outputs.upload_url }} - # asset_path: ./styles.css - # asset_name: styles.css - # asset_content_type: text/css \ No newline at end of file + gh release create "$tag" \ + --title="Release v$tag" \ + --draft \ + main.js manifest.json