docs: add MIT license and update README #7
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: Build and Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*.*.*' | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| include: | |
| - platform: ubuntu-latest | |
| goos: linux | |
| goarch: amd64 | |
| - platform: ubuntu-latest | |
| goos: linux | |
| goarch: arm64 | |
| - platform: windows-latest | |
| goos: windows | |
| goarch: amd64 | |
| - platform: windows-latest | |
| goos: windows | |
| goarch: arm64 | |
| - platform: macos-latest | |
| goos: darwin | |
| goarch: amd64 | |
| - platform: macos-latest | |
| goos: darwin | |
| goarch: arm64 | |
| runs-on: ${{ matrix.platform }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.21.x' | |
| cache: false | |
| - name: Install dependencies | |
| run: go mod download | |
| - name: Build codes | |
| shell: bash | |
| run: | | |
| if [ "${{ matrix.goos }}" = "windows" ]; then | |
| go build -o codes.exe ./cmd/codes | |
| else | |
| go build -o codes ./cmd/codes | |
| fi | |
| - name: Test | |
| shell: bash | |
| run: | | |
| if [ "${{ matrix.goos }}" = "windows" ]; then | |
| ./codes.exe version | |
| else | |
| ./codes version | |
| fi | |
| - name: Set binary name | |
| id: binary | |
| shell: bash | |
| run: | | |
| if [ "${{ matrix.goos }}" = "windows" ]; then | |
| echo "name=codes.exe" >> $GITHUB_OUTPUT | |
| else | |
| echo "name=codes" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: codes-${{ matrix.goos }}-${{ matrix.goarch }} | |
| path: ${{ steps.binary.outputs.name }} | |
| retention-days: 7 | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Prepare release files | |
| run: | | |
| mkdir -p release | |
| for dir in artifacts/codes-*; do | |
| platform=$(basename $dir | sed 's/codes-//') | |
| if [ -f "$dir/codes.exe" ]; then | |
| mv "$dir/codes.exe" "release/codes-$platform.exe" | |
| elif [ -f "$dir/codes" ]; then | |
| mv "$dir/codes" "release/codes-$platform" | |
| fi | |
| done | |
| ls -la release/ | |
| - name: Create release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: release/* | |
| draft: false | |
| prerelease: false | |
| body: | | |
| Cross-platform builds for codes CLI tool | |
| - Linux (amd64, arm64) | |
| - Windows (amd64, arm64) | |
| - macOS (amd64, arm64) |