|
| 1 | +name: Go |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["master"] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + bump: |
| 9 | + description: "Which part of the version to bump?" |
| 10 | + required: false |
| 11 | + default: "patch" |
| 12 | + type: choice |
| 13 | + options: |
| 14 | + - patch |
| 15 | + - minor |
| 16 | + - major |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: write |
| 20 | + |
| 21 | +jobs: |
| 22 | + determine-version: |
| 23 | + if: github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch' |
| 24 | + runs-on: ubuntu-latest |
| 25 | + outputs: |
| 26 | + tag: ${{ steps.next_version.outputs.tag }} |
| 27 | + current_tag: ${{ steps.current_tag.outputs.current_tag }} |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v4 |
| 30 | + with: |
| 31 | + fetch-depth: 0 |
| 32 | + |
| 33 | + - name: Get Current Tag |
| 34 | + id: current_tag |
| 35 | + run: | |
| 36 | + current_tag=$(git describe --tags --abbrev=0 HEAD^) |
| 37 | + echo "current_tag=$current_tag" >> $GITHUB_ENV |
| 38 | + echo "::set-output name=current_tag::$current_tag" |
| 39 | + env: |
| 40 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 41 | + |
| 42 | + - name: Determine next version |
| 43 | + id: next_version |
| 44 | + uses: actions/github-script@v6 |
| 45 | + env: |
| 46 | + BUMP: ${{ github.event.inputs.bump || 'patch' }} |
| 47 | + with: |
| 48 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 49 | + script: | |
| 50 | + const { owner, repo } = context.repo; |
| 51 | + const bump = process.env.BUMP || 'patch'; |
| 52 | +
|
| 53 | + console.log(`Selected bump: ${bump}`); |
| 54 | +
|
| 55 | + const latest = await github.rest.repos.getLatestRelease({ owner, repo }).catch(() => null); |
| 56 | + const currentVersion = latest ? latest.data.tag_name.replace(/^v/, '') : '0.0.0'; |
| 57 | +
|
| 58 | + let [major, minor, patch] = currentVersion.split('.').map(Number); |
| 59 | +
|
| 60 | + switch (bump) { |
| 61 | + case 'major': |
| 62 | + major++; |
| 63 | + minor = 0; |
| 64 | + patch = 0; |
| 65 | + break; |
| 66 | + case 'minor': |
| 67 | + minor++; |
| 68 | + patch = 0; |
| 69 | + break; |
| 70 | + default: |
| 71 | + patch++; |
| 72 | + } |
| 73 | +
|
| 74 | + const nextVersion = `v${major}.${minor}.${patch}`; |
| 75 | + console.log(`Next version: ${nextVersion}`); |
| 76 | + core.setOutput('tag', nextVersion); |
| 77 | +
|
| 78 | + build: |
| 79 | + runs-on: ubuntu-latest |
| 80 | + needs: determine-version |
| 81 | + steps: |
| 82 | + - uses: actions/checkout@v4 |
| 83 | + with: |
| 84 | + fetch-depth: 0 |
| 85 | + lfs: true |
| 86 | + submodules: "recursive" |
| 87 | + |
| 88 | + - name: Set up Rust |
| 89 | + uses: dtolnay/rust-toolchain@stable |
| 90 | + with: |
| 91 | + targets: aarch64-apple-ios,aarch64-apple-ios-sim,x86_64-apple-ios |
| 92 | + |
| 93 | + - name: Build IOS |
| 94 | + run: ./build_ios.sh |
| 95 | + |
| 96 | + # - name: Upload build artifact |
| 97 | + # uses: actions/upload-artifact@v4 |
| 98 | + # with: |
| 99 | + # name: ios-build |
| 100 | + # path: | |
| 101 | + # ios-build.tar.gz |
| 102 | + |
| 103 | + # release: |
| 104 | + # runs-on: ubuntu-latest |
| 105 | + # needs: |
| 106 | + # - build |
| 107 | + # - determine-version |
| 108 | + # steps: |
| 109 | + # - name: Download all artifacts |
| 110 | + # uses: actions/download-artifact@v4 |
| 111 | + |
| 112 | + # - name: Create Release |
| 113 | + # id: create_release |
| 114 | + # uses: actions/create-release@v1 |
| 115 | + # env: |
| 116 | + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 117 | + # with: |
| 118 | + # tag_name: ${{ needs.determine-version.outputs.tag }} |
| 119 | + # release_name: Release ${{ needs.determine-version.outputs.tag }} |
| 120 | + # draft: false |
| 121 | + # body: | |
| 122 | + # **Full Changelog**: https://github.com/argon-chat/k3sd/compare/${{ needs.determine-version.outputs.current_tag }}...${{ needs.determine-version.outputs.tag }} |
| 123 | + # prerelease: false |
| 124 | + |
| 125 | + # - name: Upload Linux AMD64 Release Asset |
| 126 | + # uses: actions/upload-release-asset@v1 |
| 127 | + # env: |
| 128 | + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 129 | + # with: |
| 130 | + # upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 131 | + # asset_path: ./k3sd-linux-amd64/k3sd-linux-amd64.tar.gz |
| 132 | + # asset_name: k3sd-linux-amd64.tar.gz |
| 133 | + # asset_content_type: application/gzip |
0 commit comments