Build and attach artifacts #76
Workflow file for this run
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
# This workflow runs when new releases are published. | |
# It builds the artifacts using `npm run package`. | |
# QEMU emulation is used for arm64 builds. | |
# The crypto base key for injection is read from the `FILEN_CLI_CRYPTO_BASE_KEY` environment variable. | |
# The current version is injected. | |
# All build artifacts are then attached to the release. | |
name: Build and attach artifacts | |
on: | |
release: | |
types: [published] | |
jobs: | |
build-and-publish-binaries: | |
name: Build artifacts and attach to release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set version | |
uses: jacobtomlinson/gha-find-replace@v3 | |
with: | |
include: "package.json" | |
find: '"version": "0.0.0"' | |
replace: '"version": "${{ github.event.release.tag_name }}"' | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20.x" | |
- run: npm ci | |
- run: npm run package-all | |
env: | |
FILEN_CLI_CRYPTO_BASE_KEY: ${{ secrets.FILEN_CLI_CRYPTO_BASE_KEY }} | |
- name: Check info | |
run: node dist/bundle.js --help | |
- name: Rename artifacts to include release number | |
run: | | |
mv dist/filen-cli-win-x64.exe dist/filen-cli-${{ github.event.release.tag_name }}-win-x64.exe | |
mv dist/filen-cli-linux-x64 dist/filen-cli-${{ github.event.release.tag_name }}-linux-x64 | |
mv dist/filen-cli-macos-x64 dist/filen-cli-${{ github.event.release.tag_name }}-macos-x64 | |
mv dist/filen-cli-win-arm64.exe dist/filen-cli-${{ github.event.release.tag_name }}-win-arm64.exe | |
mv dist/filen-cli-linux-arm64 dist/filen-cli-${{ github.event.release.tag_name }}-linux-arm64 | |
mv dist/filen-cli-macos-arm64 dist/filen-cli-${{ github.event.release.tag_name }}-macos-arm64 | |
- name: Attach artifacts to release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: | | |
dist/filen-cli-${{ github.event.release.tag_name }}-win-x64.exe | |
dist/filen-cli-${{ github.event.release.tag_name }}-linux-x64 | |
dist/filen-cli-${{ github.event.release.tag_name }}-macos-x64 | |
dist/filen-cli-${{ github.event.release.tag_name }}-win-arm64.exe | |
dist/filen-cli-${{ github.event.release.tag_name }}-linux-arm64 | |
dist/filen-cli-${{ github.event.release.tag_name }}-macos-arm64 | |
build-and-publish-npm: | |
name: Build and publish to npm | |
runs-on: ubuntu-latest | |
#todo: if: ${{ github.event.release.prerelease == false }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set version | |
uses: jacobtomlinson/gha-find-replace@v3 | |
with: | |
include: "package.json" | |
find: '"version": "0.0.0"' | |
replace: '"version": "${{ github.event.release.tag_name }}"' | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20.x" | |
registry-url: "https://registry.npmjs.org" | |
- run: npm ci | |
- run: npm publish --access public # includes build | |
env: | |
FILEN_CLI_CRYPTO_BASE_KEY: ${{ secrets.FILEN_CLI_CRYPTO_BASE_KEY }} | |
FILEN_IS_NPM_PACKAGE: true | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} | |
build-and-publish-docker: | |
name: Build docker image | |
runs-on: ubuntu-latest | |
if: ${{ github.event.release.prerelease == false }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set version | |
uses: jacobtomlinson/gha-find-replace@v3 | |
with: | |
include: "package.json" | |
find: '"version": "0.0.0"' | |
replace: '"version": "${{ github.event.release.tag_name }}"' | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: filen/cli:latest,filen/cli:${{ github.event.release.tag_name }} |