From d786a5f50f40643940ff11f10df29c9d767a4610 Mon Sep 17 00:00:00 2001 From: uphy Date: Sat, 3 Feb 2024 21:16:14 +0900 Subject: [PATCH] add beta deploy job --- .github/workflows/publish-beta.yml | 64 ++++++++++++++++++++++++++++++ .github/workflows/publish.yml | 61 +++++++--------------------- manifest-beta.json | 10 +++++ 3 files changed, 88 insertions(+), 47 deletions(-) create mode 100644 .github/workflows/publish-beta.yml create mode 100644 manifest-beta.json diff --git a/.github/workflows/publish-beta.yml b/.github/workflows/publish-beta.yml new file mode 100644 index 0000000..030dcd7 --- /dev/null +++ b/.github/workflows/publish-beta.yml @@ -0,0 +1,64 @@ +name: Build plugin + +on: + push: + # Sequence of patterns matched against refs/tags + tags: + - "*.*.*-beta*" + +env: + PLUGIN_NAME: obsidian-reminder + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: actions/checkout@v2 + with: + ref: develop + - name: Check if the tag commit is equal to the latest commit + run: | + if [ "$(git rev-parse ${{ github.ref }})" != "$(git rev-parse develop)" ]; then + echo "Tag commit is not equal to the latest commit" + exit 1 + fi + - name: Update the versions + run: | + version=$(git tag --sort version:refname | tail -n 1) + echo "RELEASE_VERSION=$version" >> $GITHUB_ENV + + # update manifest version + sed -i "s/\"version\": \".*\"/\"version\": \"$version\"/" manifest-beta.json + + # commit and push the changes + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add manifest-beta.json + git commit -m "Update the version to $version" + git push develop + - name: Use Node.js + uses: actions/setup-node@v1 + with: + node-version: "16.x" # You might need to adjust this value to your own version + - name: Build + id: build + run: | + npm ci + 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 }} + - name: Create Release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ github.ref }} + name: ${{ env.RELEASE_VERSION }} + draft: true + prerelease: false + files: | + ${{ env.PLUGIN_NAME }}.zip + main.js + manifest.json + styles.css diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c218508..278a842 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -5,6 +5,7 @@ on: # Sequence of patterns matched against refs/tags tags: - "*.*.*" # Push events to matching any tag format, i.e. 1.0, 20.15.10 + - "!*.*.*-beta*" env: PLUGIN_NAME: obsidian-reminder @@ -15,6 +16,12 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Check if the tag commit is contained in master branch + run: | + if ! git merge-base --is-ancestor ${{ github.ref }} master; then + echo "Tag commit is not contained in master branch" + exit 1 + fi - name: Use Node.js uses: actions/setup-node@v1 with: @@ -27,55 +34,15 @@ jobs: mkdir ${{ env.PLUGIN_NAME }} cp main.js manifest.json styles.css ${{ env.PLUGIN_NAME }} zip -r ${{ env.PLUGIN_NAME }}.zip ${{ env.PLUGIN_NAME }} - 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: softprops/action-gh-release@v1 with: tag_name: ${{ github.ref }} - release_name: ${{ github.ref }} + name: ${{ env.RELEASE_VERSION }} draft: false prerelease: false - - name: Upload zip file - id: upload-zip - uses: actions/upload-release-asset@v1 - 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 - - name: Upload styles.css - id: upload-style - 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 + files: | + ${{ env.PLUGIN_NAME }}.zip + main.js + manifest.json + styles.css diff --git a/manifest-beta.json b/manifest-beta.json new file mode 100644 index 0000000..444f24a --- /dev/null +++ b/manifest-beta.json @@ -0,0 +1,10 @@ +{ + "id": "obsidian-reminder-plugin", + "name": "Reminder", + "version": "1.1.15", + "minAppVersion": "1.0.3", + "description": "Reminder plugin for Obsidian. This plugin adds feature to manage TODOs with reminder.", + "author": "uphy", + "authorUrl": "https://obsidian.md/about", + "isDesktopOnly": false +}