|
23 | 23 | inputs: |
24 | 24 | version: |
25 | 25 | description: 'The version to release' |
26 | | - required: true |
| 26 | + required: false |
27 | 27 | type: string |
28 | 28 | base_rc_version: |
29 | 29 | description: 'The base RC version to use to create the final release. Should be formatted as X.Y.Z-RC.N' |
30 | 30 | type: string |
31 | 31 | required: false |
| 32 | + push: |
| 33 | + branches: |
| 34 | + - master |
| 35 | + paths: |
| 36 | + - 'oss_version.txt' |
32 | 37 |
|
33 | 38 | jobs: |
| 39 | + get_version: |
| 40 | + runs-on: ubuntu-latest |
| 41 | + outputs: |
| 42 | + version: ${{ steps.get_version.outputs.version }} |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v4 |
| 45 | + - id: get_version |
| 46 | + run: | |
| 47 | + if [ -f "oss_version.txt" ]; then |
| 48 | + if [[ "${{ github.event.inputs.version }}" != "" ]]; then |
| 49 | + echo "Error: The 'version' input field must not be set for repositories using 'oss_version.txt' (like j2cl)." |
| 50 | + exit 1 |
| 51 | + fi |
| 52 | + version=$(xargs < oss_version.txt) |
| 53 | + echo "Using version from oss_version.txt: ${version}." |
| 54 | + echo "version=${version}" >> "$GITHUB_OUTPUT" |
| 55 | + else |
| 56 | + echo "version=${{ github.event.inputs.version }}" >> "$GITHUB_OUTPUT" |
| 57 | + fi |
| 58 | +
|
34 | 59 | validate_inputs: |
| 60 | + needs: get_version |
35 | 61 | runs-on: ubuntu-latest |
36 | 62 | steps: |
37 | | - - name: Validate base_rc_version |
| 63 | + - name: Validate inputs |
38 | 64 | run: | |
| 65 | + version="${{ needs.get_version.outputs.version }}" |
| 66 | + if [[ -z "$version" ]]; then |
| 67 | + echo "Error: Release version is missing. It must be provided via the 'version' input or 'oss_version.txt' file." |
| 68 | + exit 1 |
| 69 | + fi |
| 70 | +
|
39 | 71 | base_rc_version="${{ github.event.inputs.base_rc_version }}" |
40 | 72 | if [[ -z "$base_rc_version" ]]; then |
41 | 73 | echo "The base RC version field is empty, no validation needed." |
42 | 74 | exit 0 |
43 | 75 | fi |
44 | 76 |
|
45 | | - version="${{ github.event.inputs.version }}" |
46 | 77 | repo_name="${{ github.event.repository.name }}" |
47 | 78 | RC_REGEX='^([0-9]+\.[0-9]+\.[0-9]+)-RC\.?[0-9]+$' |
48 | 79 | VERSION_REGEX='^[0-9]+\.[0-9]+\.[0-9]+$' |
|
82 | 113 | fi |
83 | 114 |
|
84 | 115 | release: |
85 | | - needs: validate_inputs |
| 116 | + needs: [validate_inputs, get_version] |
86 | 117 | uses: google/j2cl/.github/workflows/release_common.yaml@master |
87 | 118 |
|
88 | 119 | permissions: |
|
92 | 123 | id-token: write |
93 | 124 | attestations: write |
94 | 125 |
|
95 | | - # Pass the inputs from the manual trigger to the reusable workflow. |
| 126 | + # Pass the inputs from the trigger to the reusable workflow. |
96 | 127 | with: |
97 | | - version: ${{ github.event.inputs.version }} |
| 128 | + version: ${{ needs.get_version.outputs.version }} |
98 | 129 | git_ref: ${{ github.event.inputs.base_rc_version && format('refs/tags/{0}', github.event.inputs.base_rc_version) || github.ref }} |
99 | 130 | publish_to_sonatype: ${{ github.event.repository.name != 'jsinterop-generator' && github.event.repository.name != 'j2cl' }} |
100 | 131 | publish_to_bcr: ${{ github.event.repository.name != 'jsinterop-annotations' }} |
|
0 commit comments