|
| 1 | +name: Apply DataCite Release Plan |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + plan_path: |
| 7 | + description: 'Path to the approved plan file, for example reports/release-import-plan-4.7.json' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + set_current: |
| 11 | + description: 'Update datacite-current pointers while generating outputs.' |
| 12 | + required: false |
| 13 | + default: true |
| 14 | + type: boolean |
| 15 | + commit_generated_files: |
| 16 | + description: 'Commit generated source and output files back to the selected branch.' |
| 17 | + required: false |
| 18 | + default: true |
| 19 | + type: boolean |
| 20 | + apply_controlled_lists: |
| 21 | + description: 'Enable the controlled-list module.' |
| 22 | + required: false |
| 23 | + default: true |
| 24 | + type: boolean |
| 25 | + apply_simple_properties: |
| 26 | + description: 'Enable the simple-property module.' |
| 27 | + required: false |
| 28 | + default: true |
| 29 | + type: boolean |
| 30 | + apply_property_groups: |
| 31 | + description: 'Enable the property-group module.' |
| 32 | + required: false |
| 33 | + default: true |
| 34 | + type: boolean |
| 35 | + apply_complex_structures: |
| 36 | + description: 'Enable the complex-structure module.' |
| 37 | + required: false |
| 38 | + default: true |
| 39 | + type: boolean |
| 40 | + apply_renames: |
| 41 | + description: 'Enable the rename module.' |
| 42 | + required: false |
| 43 | + default: false |
| 44 | + type: boolean |
| 45 | + apply_removals: |
| 46 | + description: 'Enable the removal module.' |
| 47 | + required: false |
| 48 | + default: false |
| 49 | + type: boolean |
| 50 | + |
| 51 | +permissions: |
| 52 | + contents: write |
| 53 | + |
| 54 | +jobs: |
| 55 | + apply-release-plan: |
| 56 | + runs-on: ubuntu-latest |
| 57 | + |
| 58 | + steps: |
| 59 | + - name: Checkout |
| 60 | + uses: actions/checkout@v6 |
| 61 | + with: |
| 62 | + fetch-depth: 0 |
| 63 | + |
| 64 | + - name: Setup Node |
| 65 | + uses: actions/setup-node@v6 |
| 66 | + with: |
| 67 | + node-version: '20' |
| 68 | + |
| 69 | + - name: Apply approved release plan |
| 70 | + run: | |
| 71 | + modules=() |
| 72 | +
|
| 73 | + if [ "${{ inputs.apply_controlled_lists }}" = "true" ]; then |
| 74 | + modules+=(controlled-list) |
| 75 | + fi |
| 76 | + if [ "${{ inputs.apply_simple_properties }}" = "true" ]; then |
| 77 | + modules+=(simple-property) |
| 78 | + fi |
| 79 | + if [ "${{ inputs.apply_property_groups }}" = "true" ]; then |
| 80 | + modules+=(property-group) |
| 81 | + fi |
| 82 | + if [ "${{ inputs.apply_complex_structures }}" = "true" ]; then |
| 83 | + modules+=(complex-structure) |
| 84 | + fi |
| 85 | + if [ "${{ inputs.apply_renames }}" = "true" ]; then |
| 86 | + modules+=(rename) |
| 87 | + fi |
| 88 | + if [ "${{ inputs.apply_removals }}" = "true" ]; then |
| 89 | + modules+=(removal) |
| 90 | + fi |
| 91 | +
|
| 92 | + module_csv=$(IFS=, ; echo "${modules[*]}") |
| 93 | +
|
| 94 | + args=(--plan "${{ inputs.plan_path }}") |
| 95 | + if [ -n "$module_csv" ]; then |
| 96 | + args+=(--modules "$module_csv") |
| 97 | + fi |
| 98 | + if [ "${{ inputs.set_current }}" = "true" ]; then |
| 99 | + args+=(--set-current) |
| 100 | + fi |
| 101 | +
|
| 102 | + node scripts/apply-datacite-release-plan.js "${args[@]}" |
| 103 | +
|
| 104 | + - name: Resolve apply artifact paths |
| 105 | + run: | |
| 106 | + RESOLVED_VERSION=$(basename "${{ inputs.plan_path }}" .json | sed 's/^release-import-plan-//') |
| 107 | + REPORT_PATH="reports/release-apply-${RESOLVED_VERSION}.md" |
| 108 | + echo "RESOLVED_VERSION=$RESOLVED_VERSION" >> "$GITHUB_ENV" |
| 109 | + echo "REPORT_PATH=$REPORT_PATH" >> "$GITHUB_ENV" |
| 110 | +
|
| 111 | + - name: Add apply report to workflow summary |
| 112 | + run: | |
| 113 | + cat "$REPORT_PATH" >> "$GITHUB_STEP_SUMMARY" |
| 114 | +
|
| 115 | + - name: Commit generated files |
| 116 | + if: ${{ inputs.commit_generated_files }} |
| 117 | + env: |
| 118 | + VERSION: ${{ env.RESOLVED_VERSION }} |
| 119 | + run: | |
| 120 | + git config user.name "github-actions[bot]" |
| 121 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 122 | + git add \ |
| 123 | + reports/release-import-plan-*.md \ |
| 124 | + reports/release-apply-*.md \ |
| 125 | + manifest/release-matrix-*.json \ |
| 126 | + manifest/datacite-*.json \ |
| 127 | + dist/datacite-*.jsonld \ |
| 128 | + dist/datacite-*.ttl \ |
| 129 | + dist/datacite-*.rdf \ |
| 130 | + context/fullcontext.jsonld \ |
| 131 | + property/*.jsonld \ |
| 132 | + class/*.jsonld \ |
| 133 | + vocab/*/*.jsonld \ |
| 134 | + class/index.html \ |
| 135 | + context/index.html \ |
| 136 | + dist/index.html \ |
| 137 | + manifest/index.html \ |
| 138 | + property/index.html \ |
| 139 | + vocab/index.html \ |
| 140 | + index.html |
| 141 | +
|
| 142 | + if git diff --cached --quiet; then |
| 143 | + echo "No generated changes to commit." |
| 144 | + exit 0 |
| 145 | + fi |
| 146 | +
|
| 147 | + git commit -m "chore: apply DataCite release plan ${VERSION}" |
| 148 | + git push origin HEAD:${GITHUB_REF_NAME} |
| 149 | +
|
| 150 | + - name: Upload apply artifacts |
| 151 | + uses: actions/upload-artifact@v7 |
| 152 | + with: |
| 153 | + name: datacite-release-apply-${{ env.RESOLVED_VERSION }} |
| 154 | + path: | |
| 155 | + ${{ inputs.plan_path }} |
| 156 | + reports/release-import-plan-*.md |
| 157 | + ${{ env.REPORT_PATH }} |
| 158 | + manifest/release-matrix-*.json |
| 159 | + manifest/datacite-*.json |
| 160 | + dist/datacite-*.jsonld |
| 161 | + dist/datacite-*.ttl |
| 162 | + dist/datacite-*.rdf |
| 163 | + context/fullcontext.jsonld |
| 164 | + property/*.jsonld |
| 165 | + class/*.jsonld |
| 166 | + vocab/*/*.jsonld |
| 167 | + class/index.html |
| 168 | + context/index.html |
| 169 | + dist/index.html |
| 170 | + manifest/index.html |
| 171 | + property/index.html |
| 172 | + vocab/index.html |
| 173 | + index.html |
0 commit comments