|
| 1 | +name: Release new version |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [dev] |
| 6 | + |
| 7 | +env: |
| 8 | + DOTNET_VERSION: 10.0 |
| 9 | + STANDALONE_PROJECT: StarMap.Loader/StarMap.Loader.csproj |
| 10 | + LAUNCHER_PROJECT: StarMap.Launcher/StarMap.Launcher.csproj |
| 11 | + API_PROJECT: StarMap.API/StarMap.API.csproj |
| 12 | + STANDALONE_OUTPUT_PATH: ./publish/standalone |
| 13 | + LAUNCHER_OUTPUT_PATH: ./publish/launcher |
| 14 | + OUTPUT_PATH: ./publish |
| 15 | + NUGET_SOURCE: "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" |
| 16 | + EXCLUDE: "*.pdb *.xml" |
| 17 | + |
| 18 | +jobs: |
| 19 | + build: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + outputs: |
| 22 | + new_version: ${{ steps.version.outputs.new_version }} |
| 23 | + prev_version: ${{ steps.version.outputs.prev_version }} |
| 24 | + hash_version: ${{ steps.version.outputs.hash_version }} |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + fetch-depth: 0 |
| 29 | + fetch-tags: true |
| 30 | + |
| 31 | + - uses: actions/setup-dotnet@v4 |
| 32 | + with: |
| 33 | + dotnet-version: ${{ env.DOTNET_VERSION }} |
| 34 | + |
| 35 | + - name: Determine version bump |
| 36 | + id: version |
| 37 | + run: | |
| 38 | + git fetch --tags --force || true |
| 39 | +
|
| 40 | + # Find latest semantic version |
| 41 | + current=$(git tag -l '[0-9]*.[0-9]*.[0-9]*' | sort -V | tail -n 1) |
| 42 | + if [ -z "$current" ]; then |
| 43 | + current="0.0.0" |
| 44 | + fi |
| 45 | + echo "Latest semantic tag: $current" |
| 46 | +
|
| 47 | + ver=${current#v} |
| 48 | + major=$(printf "%s" "$ver" | awk -F. '{print $1+0}') |
| 49 | + minor=$(printf "%s" "$ver" | awk -F. '{print $2+0}') |
| 50 | + patch=$(printf "%s" "$ver" | awk -F. '{print $3+0}') |
| 51 | +
|
| 52 | + patch=$((patch+1)) |
| 53 | + new_version="${major}.${minor}.${patch}" |
| 54 | +
|
| 55 | + # Truly unique RC version |
| 56 | + hash_version="${new_version}-rc.${GITHUB_RUN_NUMBER}+${GITHUB_SHA::7}" |
| 57 | +
|
| 58 | + echo "Next version: $new_version" |
| 59 | + echo "RC version: $hash_version" |
| 60 | +
|
| 61 | + echo "prev_version=$current" >> $GITHUB_OUTPUT |
| 62 | + echo "new_version=$new_version" >> $GITHUB_OUTPUT |
| 63 | + echo "hash_version=$hash_version" >> $GITHUB_OUTPUT |
| 64 | +
|
| 65 | + - name: Setup NuGet source |
| 66 | + run: | |
| 67 | + dotnet nuget add source \ |
| 68 | + --username ${{ secrets.ORG_PACKAGE_USERNAME }} \ |
| 69 | + --password ${{ secrets.ORG_PACKAGE_TOKEN }} \ |
| 70 | + --store-password-in-clear-text \ |
| 71 | + --name github "${{ env.NUGET_SOURCE }}" |
| 72 | +
|
| 73 | + - name: Build launcher |
| 74 | + run: | |
| 75 | + dotnet publish ${{ env.LAUNCHER_PROJECT }} \ |
| 76 | + -c Release \ |
| 77 | + -o ${{ env.LAUNCHER_OUTPUT_PATH }} \ |
| 78 | + -r win-x64 \ |
| 79 | + --self-contained false \ |
| 80 | + /p:PackageVersion=${{ steps.version.outputs.hash_version }} \ |
| 81 | + /p:Version=${{ steps.version.outputs.new_version }} \ |
| 82 | + /p:AssemblyVersion=${{ steps.version.outputs.new_version }} \ |
| 83 | + /p:FileVersion=${{ steps.version.outputs.new_version }} |
| 84 | +
|
| 85 | + - name: Build standalone |
| 86 | + run: | |
| 87 | + dotnet publish ${{ env.STANDALONE_PROJECT }} \ |
| 88 | + -c Release \ |
| 89 | + -o ${{ env.STANDALONE_OUTPUT_PATH }} \ |
| 90 | + -r win-x64 \ |
| 91 | + --self-contained false \ |
| 92 | + /p:PackageVersion=${{ steps.version.outputs.hash_version }} \ |
| 93 | + /p:Version=${{ steps.version.outputs.new_version }} \ |
| 94 | + /p:AssemblyVersion=${{ steps.version.outputs.new_version }} \ |
| 95 | + /p:FileVersion=${{ steps.version.outputs.new_version }} |
| 96 | +
|
| 97 | + - name: Rename executables |
| 98 | + run: | |
| 99 | + mv ${{ env.LAUNCHER_OUTPUT_PATH }}/MyProgram.Launcher.exe ${{ env.LAUNCHER_OUTPUT_PATH }}/MyProgram.exe |
| 100 | + mv ${{ env.STANDALONE_OUTPUT_PATH }}/MyProgram.exe ${{ env.STANDALONE_OUTPUT_PATH }}/MyProgram.exe |
| 101 | +
|
| 102 | + - name: Write version file |
| 103 | + run: echo "${{ steps.version.outputs.hash_version }}" > version.txt |
| 104 | + |
| 105 | + - name: Upload build artifacts |
| 106 | + uses: actions/upload-artifact@v4 |
| 107 | + with: |
| 108 | + name: rc-build |
| 109 | + path: | |
| 110 | + ${{ env.LAUNCHER_OUTPUT_PATH }} |
| 111 | + ${{ env.STANDALONE_OUTPUT_PATH }} |
| 112 | + version.txt |
| 113 | + retention-days: 1 |
| 114 | + |
| 115 | + publish-RC-nuget: |
| 116 | + runs-on: ubuntu-latest |
| 117 | + needs: build |
| 118 | + steps: |
| 119 | + - uses: actions/checkout@v4 |
| 120 | + with: |
| 121 | + fetch-depth: 0 |
| 122 | + |
| 123 | + - uses: actions/setup-dotnet@v4 |
| 124 | + with: |
| 125 | + dotnet-version: ${{ env.DOTNET_VERSION }} |
| 126 | + |
| 127 | + - name: Download build artifacts |
| 128 | + uses: actions/download-artifact@v4 |
| 129 | + with: |
| 130 | + name: rc-build |
| 131 | + path: ./build_artifacts |
| 132 | + |
| 133 | + - name: Pack and push RC NuGet package |
| 134 | + run: | |
| 135 | + dotnet restore ${{ env.API_PROJECT }} |
| 136 | + dotnet pack ${{ env.API_PROJECT }} \ |
| 137 | + -c Release \ |
| 138 | + -o ./nupkg \ |
| 139 | + /p:PackageVersion=${{ needs.build.outputs.hash_version }} \ |
| 140 | + /p:Version=${{ needs.build.outputs.new_version }} \ |
| 141 | + /p:InformationalVersion=${{ needs.build.outputs.hash_version }} |
| 142 | + dotnet nuget add source --username "${{ github.actor }}" \ |
| 143 | + --password "${{ secrets.GITHUB_TOKEN }}" \ |
| 144 | + --store-password-in-clear-text \ |
| 145 | + --name github "${{ env.NUGET_SOURCE }}" |
| 146 | + dotnet nuget push ./nupkg/*.nupkg \ |
| 147 | + --source github \ |
| 148 | + --api-key "${{ secrets.GITHUB_TOKEN }}" \ |
| 149 | + --skip-duplicate |
| 150 | +
|
| 151 | + release-RC-zip: |
| 152 | + runs-on: ubuntu-latest |
| 153 | + needs: build |
| 154 | + steps: |
| 155 | + - uses: actions/checkout@v4 |
| 156 | + with: |
| 157 | + fetch-depth: 0 |
| 158 | + |
| 159 | + - name: Download build artifacts |
| 160 | + uses: actions/download-artifact@v4 |
| 161 | + with: |
| 162 | + name: rc-build |
| 163 | + path: ./build_artifacts |
| 164 | + |
| 165 | + - name: Ensure zip is available |
| 166 | + run: | |
| 167 | + sudo apt-get update -y |
| 168 | + sudo apt-get install -y zip |
| 169 | +
|
| 170 | + - name: Package launcher ZIP |
| 171 | + run: | |
| 172 | + cd ./build_artifacts/${{ env.LAUNCHER_OUTPUT_PATH }} |
| 173 | + zip -r $GITHUB_WORKSPACE/StarMapLauncher-RC.zip . -x ${{ env.EXCLUDE }} |
| 174 | + cd - |
| 175 | +
|
| 176 | + - name: Package standalone ZIP |
| 177 | + run: | |
| 178 | + cd ./build_artifacts/${{ env.STANDALONE_OUTPUT_PATH }} |
| 179 | + zip -r $GITHUB_WORKSPACE/StarMapStandalone-RC.zip . -x ${{ env.EXCLUDE }} |
| 180 | + cd - |
| 181 | +
|
| 182 | + - name: Update RC GitHub release |
| 183 | + uses: softprops/action-gh-release@v1 |
| 184 | + with: |
| 185 | + tag_name: rc |
| 186 | + name: Release Candidate |
| 187 | + prerelease: true |
| 188 | + files: | |
| 189 | + StarMapLauncher-RC.zip |
| 190 | + StarMapStandalone-RC.zip |
| 191 | + ./build_artifacts/version.txt |
| 192 | + env: |
| 193 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 194 | + |
| 195 | + - name: Update RC tag |
| 196 | + run: | |
| 197 | + git tag -f rc |
| 198 | + git push origin rc --force |
0 commit comments