|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "*.*.*" |
| 7 | + |
| 8 | +permissions: |
| 9 | + actions: read |
| 10 | + contents: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + validate: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Validate tag format |
| 17 | + run: | |
| 18 | + echo "Using tag: ${{ github.ref_name }}" |
| 19 | + if ! [[ "${{ github.ref_name }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 20 | + echo "Tag format is invalid. Expected semantic versioning (e.g., 1.2.3)." |
| 21 | + exit 1 |
| 22 | + fi |
| 23 | +
|
| 24 | + build: |
| 25 | + strategy: |
| 26 | + matrix: |
| 27 | + runs-on: [ |
| 28 | + "macos-latest", |
| 29 | + "ubuntu-latest", |
| 30 | + "ubuntu-24.04-arm" |
| 31 | + ] |
| 32 | + runs-on: ${{ matrix.runs-on }} |
| 33 | + needs: |
| 34 | + - validate |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v4 |
| 37 | + with: |
| 38 | + repository: apple/swift-protobuf |
| 39 | + ref: ${{ github.ref_name }} |
| 40 | + - name: Set build configuration |
| 41 | + id: build-info |
| 42 | + run: | |
| 43 | + if [[ $(uname) == "Darwin" ]]; then |
| 44 | + echo "build_os=macos" >> "$GITHUB_OUTPUT" |
| 45 | + elif [[ $(uname) == "Linux" ]]; then |
| 46 | + echo "build_os=linux" >> "$GITHUB_OUTPUT" |
| 47 | + else |
| 48 | + echo "Unsupported OS" |
| 49 | + exit 1 |
| 50 | + fi |
| 51 | +
|
| 52 | + if [[ "$(uname -m)" == "aarch64" ]]; then |
| 53 | + echo "build_arch=arm64" >> "$GITHUB_OUTPUT" |
| 54 | + elif [[ "$(uname -m)" == "arm64" ]]; then |
| 55 | + echo "build_arch=arm64" >> "$GITHUB_OUTPUT" |
| 56 | + elif [[ "$(uname -m)" == "x86_64" ]]; then |
| 57 | + echo "build_arch=amd64" >> "$GITHUB_OUTPUT" |
| 58 | + elif [[ "$(uname -m)" == "amd64" ]]; then |
| 59 | + echo "build_arch=amd64" >> "$GITHUB_OUTPUT" |
| 60 | + else |
| 61 | + echo "Unsupported architecture" |
| 62 | + exit 1 |
| 63 | + fi |
| 64 | + - name: Build protoc-gen-swift |
| 65 | + run: | |
| 66 | + echo "Building protoc-gen-swift-${{ steps.build-info.outputs.build_os }}-${{ steps.build-info.outputs.build_arch }}" |
| 67 | + swift build -c release |
| 68 | + mv .build/release/protoc-gen-swift protoc-gen-swift-${{ steps.build-info.outputs.build_os }}-${{ steps.build-info.outputs.build_arch }} |
| 69 | + - uses: actions/upload-artifact@v4 |
| 70 | + with: |
| 71 | + name: protoc-gen-swift-${{ steps.build-info.outputs.build_os }}-${{ steps.build-info.outputs.build_arch }} |
| 72 | + path: protoc-gen-swift-${{ steps.build-info.outputs.build_os }}-${{ steps.build-info.outputs.build_arch }} |
| 73 | + |
| 74 | + publish: |
| 75 | + runs-on: ubuntu-latest |
| 76 | + needs: |
| 77 | + - build |
| 78 | + steps: |
| 79 | + - uses: actions/download-artifact@v4 |
| 80 | + - run: ls -l; ls -l protoc-gen-swift-* |
| 81 | + - uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda |
| 82 | + with: |
| 83 | + files: '**/protoc-gen-swift-*' |
0 commit comments