Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1name: Release Workflow
2
3on:
4 push:
5 branches:
6 - stable
7
8jobs:
9 build:
10 runs-on: ubuntu-latest
11
12 steps:
13 # Step 1: Checkout the repository
14 - name: Checkout
15 uses: actions/checkout@v4
16
17 # Step 2: Set up JDK 1.8
18 - name: Set up JDK 1.8
19 uses: actions/setup-java@v2
20 with:
21 distribution: 'temurin'
22 java-version: 8
23
24 # Step 3: Get the version from pom.xml
25 - name: Get the version from pom.xml
26 id: get_version
27 run: echo "PROJECT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
28
29 # Step 4: Fail if snapshot version
30 - name: Fail if snapshot version
31 run: |
32 if [[ $PROJECT_VERSION == *"-SNAPSHOT"* ]]; then
33 echo "Snapshot versions are not releasable"
34 exit 0
35 fi
36
37 # Step 5: Generate custom release version
38 - name: Generate Release Version
39 id: release_version
40 run: |
41 DATE=$(date +'%y%m%d-%H%M')
42 SHA=$(echo $GITHUB_SHA | cut -c1-7)
43 RELEASE_VERSION="${PROJECT_VERSION}-${DATE}-${SHA}"
44 echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
45
46 # Step 6: Create version.properties file
47 - name: Create version.properties file
48 run: |
49 mkdir -p src/main/resources
50
51 # Application Information
52 APP_NAME=$(mvn help:evaluate -Dexpression=project.name -q -DforceStdout)
53
54 # Core Metadata
55 echo "version=${{ env.RELEASE_VERSION }}" >> src/main/resources/version.properties
56 echo "build_timestamp=$(date --utc +'%Y-%m-%dT%H:%M:%SZ')" >> src/main/resources/version.properties
57 echo "git_branch=${{ github.ref_name }}" >> src/main/resources/version.properties
58 echo "git_commit=${GITHUB_SHA}" >> src/main/resources/version.properties
59
60 echo "app_name=${APP_NAME}" >> src/main/resources/version.properties
61 echo "release_version=${{ env.RELEASE_VERSION }}" >> src/main/resources/version.properties
62 echo "maven_version=${{ env.PROJECT_VERSION }}" >> src/main/resources/version.properties
63
64 # Build Type
65 if [[ "${{ github.ref }}" == "refs/heads/master" || "${{ github.ref }}" == "refs/heads/main" ]]; then
66 BUILD_TYPE="production"
67 elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
68 BUILD_TYPE="pull_request"
69 else
70 BUILD_TYPE="development"
71 fi
72 echo "build_type=${BUILD_TYPE}" >> src/main/resources/version.properties
73
74 # CI/CD Metadata
75 echo "workflow_name=${{ github.workflow }}" >> src/main/resources/version.properties
76 echo "workflow_run_id=${{ github.run_id }}" >> src/main/resources/version.properties
77 echo "workflow_run_number=${{ github.run_number }}" >> src/main/resources/version.properties
78
79 # Team or Author Information
80 echo "build_author=${{ github.actor }}" >> src/main/resources/version.properties
81
82 # Step 7: Build with Maven
83 - name: Build with Maven
84 run: mvn clean package
85
86 # Step 8: Create GitHub Release
87 - name: Create GitHub Release
88 if: ${{ !endsWith(env.PROJECT_VERSION, '-SNAPSHOT') }}
89 uses: softprops/action-gh-release@v1
90 with:
91 tag_name: ${{ env.RELEASE_VERSION }}
92 name: ${{ env.RELEASE_VERSION }}
93 files: |
94 target/*.jar
95 env:
96 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}