feat: listed new features and how to use npx #141
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: Build and Release | |
| permissions: | |
| contents: write | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| tags: | |
| - "*.*.*" | |
| pull_request: | |
| branches: [ "main" ] | |
| jobs: | |
| test_and_lint: | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Install dependencies | |
| run: | | |
| go install golang.org/x/tools/cmd/goimports@latest | |
| go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest | |
| - name: Lint | |
| run: | | |
| go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.2.2 | |
| make lint || true | |
| - name: Security scan | |
| run: | | |
| go install golang.org/x/vuln/cmd/govulncheck@latest | |
| govulncheck -show verbose ./... || true | |
| - name: Test | |
| run: | | |
| make build test | |
| build_on_macos: | |
| runs-on: macos-latest | |
| permissions: | |
| contents: read | |
| needs: [test_and_lint] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Install dependencies | |
| run: | | |
| go install golang.org/x/tools/cmd/goimports@latest | |
| - name: Set version | |
| if: github.ref_type == 'tag' | |
| run: | | |
| sed -i '' 's/version = \"dev\"/version = \"${{ github.ref_name }}\"/' cli/root.go | |
| - name: Build | |
| run: | | |
| GOARCH=arm64 go build -ldflags="-s -w" -o mobilecli-arm64 | |
| GOARCH=amd64 go build -ldflags="-s -w" -o mobilecli-amd64 | |
| lipo mobilecli-arm64 mobilecli-amd64 -create -output mobilecli-darwin | |
| rm mobilecli-arm64 mobilecli-amd64 | |
| ./mobilecli-darwin --version | |
| - name: Upload macos build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: macos-build | |
| path: | | |
| mobilecli-darwin | |
| retention-days: 1 | |
| overwrite: true | |
| build_on_linux: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| needs: [test_and_lint] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Install dependencies | |
| run: | | |
| go install golang.org/x/tools/cmd/goimports@latest | |
| go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest | |
| - name: Set version | |
| if: github.ref_type == 'tag' | |
| run: | | |
| sed -i 's/version = \"dev\"/version = \"${{ github.ref_name }}\"/' main.go | |
| - name: Build | |
| run: | | |
| GOARCH=arm64 go build -ldflags="-s -w" -o mobilecli-linux-arm64 | |
| GOARCH=amd64 go build -ldflags="-s -w" -o mobilecli-linux-amd64 | |
| ./mobilecli-linux-amd64 --version | |
| - name: Upload macos build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-build | |
| path: | | |
| mobilecli-linux-arm64 | |
| mobilecli-linux-amd64 | |
| retention-days: 1 | |
| overwrite: true | |
| build_on_windows: | |
| runs-on: windows-latest | |
| permissions: | |
| contents: read | |
| needs: [test_and_lint] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Build | |
| run: | | |
| go build -ldflags="-s -w" -o mobilecli-windows-amd64.exe | |
| env: | |
| GOARCH: amd64 | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: windows-build | |
| path: | | |
| mobilecli-windows-amd64.exe | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| needs: [build_on_linux, build_on_macos, build_on_windows] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download darwin build | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: macos-build | |
| path: mobilecli-darwin | |
| - name: Download linux build | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: linux-build | |
| path: mobilecli-linux | |
| - name: Download windows build | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: windows-build | |
| path: mobilecli-windows | |
| - name: Zip builds | |
| if: github.ref_type == 'tag' | |
| run: | | |
| mkdir dist | |
| cd dist | |
| # mac | |
| cp ../mobilecli-darwin/mobilecli-darwin mobilecli | |
| zip -9 ../mobilecli-${{ github.ref_name }}-macos.zip mobilecli | |
| rm -f mobilecli | |
| # linux-amd64 | |
| cp ../mobilecli-linux/mobilecli-linux-amd64 mobilecli | |
| zip -9 ../mobilecli-${{ github.ref_name }}-linux-amd64.zip mobilecli | |
| rm -f mobilecli | |
| # linux-arm64 | |
| cp ../mobilecli-linux/mobilecli-linux-arm64 mobilecli | |
| zip -9 ../mobilecli-${{ github.ref_name }}-linux-arm64.zip mobilecli | |
| rm -f mobilecli | |
| # windows-amd64 | |
| cp ../mobilecli-windows/mobilecli-windows-amd64.exe mobilecli.exe | |
| zip -9 ../mobilecli-${{ github.ref_name }}-windows-amd64.zip mobilecli.exe | |
| rm -f mobilecli.exe | |
| cd .. | |
| ls -l *.zip | |
| rm -rf dist | |
| - name: Upload to GitHub Release | |
| if: github.ref_type == 'tag' | |
| uses: softprops/action-gh-release@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.RELEASES_TOKEN }} | |
| with: | |
| name: Version ${{ github.ref_name }} | |
| files: | | |
| mobilecli-*.zip | |
| - name: Publish | |
| if: github.ref_type == 'tag' | |
| env: | |
| NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | |
| run: | | |
| # prepare binaries for distribution | |
| mv ./mobilecli-darwin/mobilecli-darwin publish/npm/bin | |
| mv ./mobilecli-linux/mobilecli-linux-amd64 publish/npm/bin | |
| mv ./mobilecli-linux/mobilecli-linux-arm64 publish/npm/bin | |
| mv ./mobilecli-windows/mobilecli-windows-amd64.exe publish/npm/bin | |
| chmod +x publish/npm/bin/* | |
| # setup npmrc | |
| echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" >> ~/.npmrc | |
| # publish to npm | |
| cd publish/npm | |
| npm version "${{ github.ref_name }}" --no-git-tag-version | |
| npm install | |
| npm publish --access public | |