From 1ad9072c598b0c495d303dd292f44fb14357fd4a Mon Sep 17 00:00:00 2001 From: Je Xia Date: Mon, 13 Jan 2025 17:21:53 +0800 Subject: [PATCH] Update release action (#1011) --- .github/workflows/release.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 40b51543..ea31a875 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -110,7 +110,7 @@ jobs: registry-url: 'https://registry.npmjs.org' - name: Build CLI - run: go build -ldflags="-s -w -X 'github.com/esm-dev/esm.sh/server.VERSION=${{ github.ref_name }}'" -o cli/tmp/bin/esm.sh-cli-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.ext }} cli/cmd/main.go + run: go build -ldflags="-s -w -X 'github.com/esm-dev/esm.sh/server.VERSION=${{ github.ref_name }}'" -o cli/build/bin/esm.sh-cli-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.ext }} cli/cmd/main.go env: GOOS: ${{ matrix.os }} GOARCH: ${{ matrix.arch }} @@ -120,12 +120,18 @@ jobs: uses: actions/upload-artifact@v4 with: name: esm.sh-cli-${{ matrix.os }}-${{ matrix.arch }} - path: cli/tmp/bin/esm.sh-cli-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.ext }} + path: cli/build/bin/esm.sh-cli-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.ext }} if-no-files-found: error - name: Create package.json run: echo "const[minor,patch='0']='${{ github.ref_name }}'.slice(1).split('_');const p=JSON.parse(require('fs').readFileSync('../npm/package.json','utf8'));console.log(JSON.stringify({...p,name:'@esm.sh/cli-${{ matrix.os }}-${{ matrix.arch }}',version:['0',minor,patch].join('.'),os:['${{ matrix.os }}'],cpu:['${{ matrix.arch }}'.replace('amd','x')],bin:void 0,scripts:void 0,optionalDependencies:void 0}))" | node > package.json - working-directory: cli/tmp + working-directory: cli/build + + - name: Publish Package to NPM + run: npm publish --provenance --access public + working-directory: cli/build + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} publish_esmsh_to_npm: name: Publish package "esm.sh" to NPM @@ -151,6 +157,12 @@ jobs: run: echo "const fs=require('fs');const[minor,patch='0']='${{ github.ref_name }}'.slice(1).split('_');fs.writeFileSync('package.json',fs.readFileSync('package.json','utf8').replaceAll('*',['0',minor,patch].join('.')),'utf8')" | node working-directory: cli/npm + - name: Publish Package + run: npm publish --provenance --access public + working-directory: cli/npm + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + release: name: Release runs-on: ubuntu-latest