From aa10d8f4a65c863caa429a377d53407f91c5868e Mon Sep 17 00:00:00 2001 From: Roy Li Date: Tue, 19 Sep 2023 22:44:57 +0200 Subject: [PATCH] chore: improve workflow --- .github/workflows/ci.yml | 20 ++++++----- .github/workflows/release-builtin.yml | 50 +++++++++++++++++++++++++++ .github/workflows/release.yml | 20 ++++++----- 3 files changed, 72 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/release-builtin.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 29f7031..1b9289a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,22 +17,24 @@ jobs: node-version: [18] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - - name: Cache node modules - uses: actions/cache@v1 + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v3 + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) with: - path: node_modules - key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }} + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} restore-keys: | - ${{ runner.OS }}-build-${{ env.cache-name }}- - ${{ runner.OS }}-build- - ${{ runner.OS }}- + ${{ runner.os }}-yarn- - name: yarn install, build run: | diff --git a/.github/workflows/release-builtin.yml b/.github/workflows/release-builtin.yml new file mode 100644 index 0000000..2c28872 --- /dev/null +++ b/.github/workflows/release-builtin.yml @@ -0,0 +1,50 @@ +name: Release built-in + +on: + release: + types: + - published + +jobs: + release: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + node-version: [18] + + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v3 + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: yarn install, build, bundle + run: | + yarn install + CI=false yarn build:surge + + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ./yasd.tar.gz + asset_name: built-in.tar.gz + asset_content_type: application/tar+gzip diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 84ae907..040e59b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,22 +14,24 @@ jobs: node-version: [18] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - - name: Cache node modules - uses: actions/cache@v1 + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v3 + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) with: - path: node_modules - key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }} + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} restore-keys: | - ${{ runner.OS }}-build-${{ env.cache-name }}- - ${{ runner.OS }}-build- - ${{ runner.OS }}- + ${{ runner.os }}-yarn- - name: yarn install, build, bundle run: |