Skip to content

Fix release action

Fix release action #7

Workflow file for this run

name: Release
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build_esmsh_cli:
name: Build esm.sh CLI
runs-on: ubuntu-latest
environment: release
strategy:
matrix:
include:
- os: darwin
arch: arm64
ext: ''
- os: darwin
arch: amd64
ext: ''
- os: linux
arch: arm64
ext: ''
- os: linux
arch: amd64
ext: ''
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.23.x
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
registry-url: 'https://registry.npmjs.org'
- name: Build CLI
run: go build -ldflags="-s -w -X 'github.com/esm-dev/esm.sh/server.VERSION=v136'" -o cli/tmp/bin/esm.sh${{ matrix.ext }} cli/cmd/main.go
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
CGO_ENABLED: "0"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: esm.sh-cli-${{ matrix.os }}-${{ matrix.arch }}
path: cli/tmp/bin/esm.sh${{ matrix.ext }}
if-no-files-found: error
- name: Create package.json
run: echo "const[minor,patch='0']='v136'.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
publish_esmsh_to_npm:
name: Publish package "esm.sh" to NPM
runs-on: ubuntu-latest
environment: release
needs: [build_esmsh_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: 22
registry-url: 'https://registry.npmjs.org'
- name: Update Version
run: echo "const fs=require('fs');const[minor,patch='0']='v136'.slice(1).split('_');fs.writeFileSync('package.json',fs.readFileSync('package.json','utf8').replaceAll('*',['0',minor,patch].join('.')),'utf8')" | node
working-directory: cli/npm
release:
name: Release
runs-on: ubuntu-latest
needs: [ publish_esmsh_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: |
ls .artifact
gzip .artifact/*
ls .artifact