From e7c31fa050d0b65da3bf0dd474be7abf0f96f660 Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Wed, 8 Apr 2020 14:40:37 +0800 Subject: [PATCH] build: use github actions --- .github/workflows/build.yml | 37 +++++++++++++++ .github/workflows/release-assets.yml | 68 ++++++++++++++++++++++++++++ Makefile | 8 +++- 3 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release-assets.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..21921ee --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,37 @@ +name: Build + +on: + push: + branches: + - build/* + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + + - name: Cache deps + uses: actions/cache@v1 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Retrieve vscode icons + uses: actions/checkout@v2 + with: + repository: 'vscode-icons/vscode-icons' + path: 'vscode-icons' + + - name: Build + run: | + yarn + make build diff --git a/.github/workflows/release-assets.yml b/.github/workflows/release-assets.yml new file mode 100644 index 0000000..c47adfe --- /dev/null +++ b/.github/workflows/release-assets.yml @@ -0,0 +1,68 @@ +name: Release assets when push tags + +on: + push: + tags: + - v[0-9]+.* # roughly matching version numbers + - test + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Get the ref + id: get_ref + run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3) + + - uses: actions/checkout@v1 + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + + - name: Cache deps + uses: actions/cache@v1 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Retrieve vscode icons + uses: actions/checkout@v2 + with: + repository: 'vscode-icons/vscode-icons' + path: 'vscode-icons' + + - name: Build + run: | + yarn + make build + + - name: Create Release + id: create_release + uses: actions/create-release@latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.get_ref.outputs.VERSION }} + release_name: ${{ steps.get_ref.outputs.VERSION }} + draft: false + prerelease: false + + - name: Generate release zip + run: | + make compress + + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./dist/Gitako.zip + asset_name: Gitako.zip + asset_content_type: application/zip diff --git a/Makefile b/Makefile index 02da407..841cd70 100755 --- a/Makefile +++ b/Makefile @@ -14,13 +14,17 @@ upload-for-analytics: yarn sentry-cli releases finalize "$(FULL_VERSION)" compress: - rm -f dist/gitako.zip - cd dist && zip -r gitako-$(FULL_VERSION).zip * -x *.map -x *.DS_Store + rm -f dist/Gitako.zip + cd dist && zip -r Gitako.zip * -x *.map -x *.DS_Store + +rename-compressed: + cd dist && mv Gitako.zip Gitako-$(FULL_VERSION).zip release: $(MAKE) build $(MAKE) upload-for-analytics $(MAKE) compress + $(MAKE) rename-compressed $(MAKE) compress-source compress-source: