Release #26
This file contains 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*.*.*" | |
workflow_dispatch: | |
jobs: | |
goreleaser: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Fetch all tags | |
run: git fetch --force --tags | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.18 | |
- name: Run GoReleaser | |
uses: goreleaser/goreleaser-action@v2 | |
with: | |
distribution: goreleaser | |
version: latest | |
args: release --clean | |
env: | |
GITHUB_TOKEN: ${{ secrets.PUBLISHER_TOKEN }} | |
- name: Upload binaries | |
uses: actions/upload-artifact@v4 | |
with: | |
name: binaries | |
path: | | |
dist | |
!homebrew | |
!dist/**/*.tar.gz | |
!dist/**/*.zip | |
!dist/**/*.json | |
!dist/**/*.yaml | |
!dist/**/*.txt | |
publish-binaries: | |
needs: goreleaser | |
strategy: | |
matrix: | |
os: ["forky_darwin_amd64_v1","forky_darwin_arm64","forky_linux_amd64_v1","forky_linux_arm64","forky_windows_amd64_v1", "forky_windows_arm64"] | |
runs-on: ubuntu-latest | |
name: Publish binaries for different architectures and platforms to NPM | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "16" | |
registry-url: "https://registry.npmjs.org" | |
- name: Download uploaded binaries | |
uses: actions/download-artifact@v4 | |
with: | |
name: binaries | |
- name: Set the release version | |
shell: bash | |
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV | |
- name: Publish to NPM | |
shell: bash | |
run: | | |
cd npm | |
bin="forky" | |
version="${{ env.RELEASE_VERSION }}" | |
export version | |
node_os=$(echo "${{ matrix.os }}" | cut -d "_" -f2) | |
export node_os | |
node_arch=$(echo "${{ matrix.os }}" | cut -d "_" -f3) | |
export node_arch | |
if [ "${node_os}" = "windows" ]; then | |
export node_pkg="${bin}-windows-${node_arch}" | |
else | |
export node_pkg="${bin}-${node_os}-${node_arch}" | |
fi | |
mkdir -p "${node_pkg}/bin" | |
envsubst < package.json.tmpl > "${node_pkg}/package.json" | |
if [ "${node_os}" = "windows" ]; then | |
bin="${bin}.exe" | |
fi | |
install -D ../${{ matrix.os }}/${bin} ${node_pkg}/bin/${bin} | |
cd "${node_pkg}" | |
npm publish --access public | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.NPM_API_KEY}} | |
publish-npm: | |
needs: publish-binaries | |
name: Publish base package to NPM | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "16" | |
registry-url: "https://registry.npmjs.org" | |
- name: Publish to NPM | |
shell: bash | |
run: | | |
cd npm/forky | |
yarn install | |
yarn build | |
npm publish --access public | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.NPM_API_KEY}} |