name: Release on: push: tags: - 'v*' workflow_dispatch: inputs: version: description: 'Version (e.g. 0.3.9, 不带 v 前缀)' required: true permissions: contents: write jobs: build-macos: runs-on: macos-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v5 with: go-version-file: go.mod - name: Resolve version id: ver run: | if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then echo "version=${{ inputs.version }}" >> "$GITHUB_OUTPUT" else echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" fi - name: Vet run: make vet - name: Build .app run: make app SEMVER=${{ steps.ver.outputs.version }} - name: Package .app as zip run: | VERSION="${{ steps.ver.outputs.version }}-$(git rev-parse --short HEAD)" ditto -c -k --sequesterRsrc --keepParent LMVPN.app "LMVPN-${VERSION}-macos.zip" - name: Upload artifact uses: actions/upload-artifact@v4 with: name: macos-build path: LMVPN-*-macos.zip build-windows: runs-on: windows-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v5 with: go-version-file: go.mod - name: Install make and Inno Setup shell: pwsh run: choco install make innosetup -y --no-progress - name: Add MinGW to PATH shell: bash run: echo "C:/msys64/mingw64/bin" >> "$GITHUB_PATH" - name: Resolve version id: ver shell: bash run: | if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then echo "version=${{ inputs.version }}" >> "$GITHUB_OUTPUT" else echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" fi - name: Vet shell: bash run: make vet - name: Build installer shell: bash env: MSYS_NO_PATHCONV: '1' run: make installer-windows SEMVER=${{ steps.ver.outputs.version }} MINGW_CC=gcc SHELL=bash - name: Upload artifact uses: actions/upload-artifact@v4 with: name: windows-build path: build/LMVPN-Setup-*.exe release: needs: [build-macos, build-windows] runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/') steps: - name: Download artifacts uses: actions/download-artifact@v4 with: path: artifacts merge-multiple: true - name: Create release uses: softprops/action-gh-release@v2 with: files: artifacts/* generate_release_notes: true