Release CLI v0.1.1 #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - v*.*.* | |
| jobs: | |
| build_cli: | |
| name: Build esm.sh CLI | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| include: | |
| - platform: darwin | |
| arch: arm64 | |
| goos: darwin | |
| goarch: arm64 | |
| ext: '' | |
| - platform: darwin | |
| arch: x64 | |
| goos: darwin | |
| goarch: amd64 | |
| ext: '' | |
| - platform: linux | |
| arch: arm64 | |
| goos: linux | |
| goarch: arm64 | |
| ext: '' | |
| - platform: linux | |
| arch: x64 | |
| goos: linux | |
| goarch: amd64 | |
| ext: '' | |
| - platform: win32 | |
| arch: arm64 | |
| goos: windows | |
| goarch: arm64 | |
| ext: '.exe' | |
| - platform: win32 | |
| arch: x64 | |
| goos: windows | |
| goarch: amd64 | |
| ext: '.exe' | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: 1.26.x | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Build CLI | |
| run: go build -ldflags="-s -w" -o cli/npm/cli_package/bin/esm.sh${{ matrix.ext }} main.go | |
| env: | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| CGO_ENABLED: "0" | |
| # Flat, unique names so merge-multiple does not overwrite the same nested path | |
| # (cli/npm/cli_package/bin/esm.sh) across matrix jobs. | |
| - name: Stage release binary | |
| run: cp "cli/npm/cli_package/bin/esm.sh${{ matrix.ext }}" "cli-${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.ext }}" | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: cli-${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.ext }} | |
| path: cli-${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.ext }} | |
| if-no-files-found: error | |
| - name: Create package.json | |
| run: echo "const p=JSON.parse(require('fs').readFileSync('../package.json','utf8'));console.log(JSON.stringify({...p,name:'@esm.sh/cli-${{ matrix.platform }}-${{ matrix.arch }}',version:'${{ github.ref_name }}'.slice(1),os:['${{ matrix.platform }}'],cpu:['${{ matrix.arch }}'],bin:void 0,scripts:void 0,optionalDependencies:void 0}))" | node > package.json | |
| working-directory: cli/npm/cli_package | |
| - name: Publish Package to NPM | |
| run: npm publish --provenance --access public --tag latest | |
| working-directory: cli/npm/cli_package | |
| publish_to_npm: | |
| name: Publish package "esm.sh" to NPM | |
| runs-on: ubuntu-latest | |
| needs: [build_cli] | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Update Version | |
| run: echo "const fs=require('fs');fs.writeFileSync('package.json',fs.readFileSync('package.json','utf8').replaceAll('*','${{ github.ref_name }}'.slice(1)),'utf8')" | node | |
| working-directory: cli/npm | |
| - name: Publish Package | |
| run: npm publish --provenance --access public --tag latest | |
| working-directory: cli/npm | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| needs: [publish_to_npm] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Download Artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| merge-multiple: true | |
| path: .artifact | |
| - name: Gzip Artifact | |
| run: gzip .artifact/* | |
| - name: Extract Release Note | |
| run: echo "console.log(require('fs').readFileSync('CHANGELOG-CLI.md','utf8').split('## ')[1].slice('${{ github.ref_name }}'.length).trim())" | node > release-note.txt | |
| - name: Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| body_path: release-note.txt | |
| files: .artifact/cli-*.gz |