From ae9e66bae959a50e7d4d745940000209a9c03630 Mon Sep 17 00:00:00 2001 From: Maciej Niemcewicz Date: Fri, 10 May 2024 17:13:04 +0200 Subject: [PATCH 1/2] add build action --- .github/workflows/build.yml | 45 +++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) 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..b16a146 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,45 @@ +name: Build & Release + +permissions: + contents: write + +on: + push: + branches: [ main ] + workflow_dispatch: + +jobs: + build-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Use Node.js 18.x + uses: actions/setup-node@v4 + with: + node-version: 18.x + - run: yarn + - run: yarn build + - name: After script + id: afterscript + run: | + ls -la + BUILDFOLDER="dist" + MANIFEST=$(find ./$BUILDFOLDER -name plugin-manifest.json) + [ -z $MANIFEST ] && cp plugin-manifest $BUILDFOLDER + + + MANIFEST="$BUILDFOLDER/plugin-manifest.json" + VERSION=$(jq '.version' $MANIFEST | tr -d '"') + echo "version=$VERSION" + mkdir -p output + tar -C $BUILDFOLDER -czf output/$VERSION.tar.gz . + ls -la output + echo "version=$VERSION" >> $GITHUB_ENV + - name: Release built plugin + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: output/* + tag: ${{ env.version }} + overwrite: true + file_glob: true \ No newline at end of file From 95973f250bbc69ee510b9351c41e717558627f5e Mon Sep 17 00:00:00 2001 From: Maciej Niemcewicz Date: Mon, 13 May 2024 14:26:10 +0200 Subject: [PATCH 2/2] release only on main branch && create artifact --- .github/workflows/build.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b16a146..d0c8e23 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,6 +7,7 @@ on: push: branches: [ main ] workflow_dispatch: + pull_request: jobs: build-release: @@ -19,22 +20,23 @@ jobs: node-version: 18.x - run: yarn - run: yarn build - - name: After script - id: afterscript + - name: Create tar from built plugin run: | - ls -la BUILDFOLDER="dist" MANIFEST=$(find ./$BUILDFOLDER -name plugin-manifest.json) [ -z $MANIFEST ] && cp plugin-manifest $BUILDFOLDER - - MANIFEST="$BUILDFOLDER/plugin-manifest.json" - VERSION=$(jq '.version' $MANIFEST | tr -d '"') + VERSION=$(jq '.version' $MANIFEST -r) echo "version=$VERSION" mkdir -p output tar -C $BUILDFOLDER -czf output/$VERSION.tar.gz . ls -la output echo "version=$VERSION" >> $GITHUB_ENV + - name: Create artifact + uses: actions/upload-artifact@v4 + with: + name: plugin-package + path: output - name: Release built plugin uses: svenstaro/upload-release-action@v2 with: @@ -42,4 +44,5 @@ jobs: file: output/* tag: ${{ env.version }} overwrite: true - file_glob: true \ No newline at end of file + file_glob: true + if: github.ref == 'refs/heads/main' \ No newline at end of file