|
1 | | -name: Build Midas release files and create a release |
| 1 | +name: Build MIDAS release files and publish a GitHub Release |
| 2 | + |
2 | 3 | on: |
3 | 4 | workflow_dispatch: |
4 | 5 | push: |
5 | | - branches: [ main ] |
| 6 | + branches: [main] |
6 | 7 | paths: |
7 | | - - 'src/ontology/imports/**_import.owl' |
8 | | - - 'src/ontology/imports/seed.txt' |
9 | | - - 'src/ontology/midas-data-edit.owl' |
| 8 | + - src/ontology/imports/**_import.owl |
| 9 | + - src/ontology/imports/seed.txt |
| 10 | + - src/ontology/midas-data-edit.owl |
| 11 | + |
| 12 | +defaults: |
| 13 | + run: |
| 14 | + shell: bash -eu {0} |
10 | 15 |
|
11 | 16 | jobs: |
| 17 | +# ------------------------------------------------------------ |
| 18 | +# Build job – compiles the OWL releases, commits them, and |
| 19 | +# exposes TAG as an output for the next job. |
| 20 | +# ------------------------------------------------------------ |
12 | 21 | build: |
| 22 | + name: Build release artefacts |
13 | 23 | runs-on: ubuntu-latest |
14 | 24 | container: obolibrary/odkfull:latest |
| 25 | + timeout-minutes: 60 |
15 | 26 | strategy: |
16 | 27 | max-parallel: 1 |
| 28 | + |
| 29 | + outputs: |
| 30 | + tag: ${{ steps.date.outputs.tag }} |
| 31 | + |
17 | 32 | steps: |
18 | | - - name: Get current date |
| 33 | + - name: Stamp date tag (YYYY-MM-DD) |
19 | 34 | id: date |
20 | | - shell: bash |
21 | 35 | run: | |
22 | | - echo "date=$(date +'%Y-%m-%d')" >> "$GITHUB_OUTPUT" |
23 | | - |
24 | | - - name: Checkout main branch |
25 | | - uses: actions/checkout@v2 |
| 36 | + echo "tag=v$(date +'%Y-%m-%d')" >> "$GITHUB_OUTPUT" |
26 | 37 |
|
27 | | - - name: work around permission issue |
| 38 | + - name: Checkout repository |
| 39 | + uses: actions/checkout@v4 |
| 40 | + with: |
| 41 | + fetch-depth: 0 |
| 42 | + |
| 43 | + - name: Work-around safe-directory warning |
28 | 44 | run: git config --global --add safe.directory "$GITHUB_WORKSPACE" |
29 | 45 |
|
30 | | - - name: Install zip |
| 46 | + - name: Install zip utilities |
31 | 47 | run: | |
32 | 48 | apt-get update -qq |
33 | | - apt-get install -y zip unzip |
34 | | - |
35 | | - - name: Update release files |
36 | | - run: cd src/ontology/ && make ROBOT_ENV='ROBOT_JAVA_ARGS=-Xms16G -Xmx128G' GITHUB_ACTION=true all -B |
| 49 | + DEBIAN_FRONTEND=noninteractive \ |
| 50 | + apt-get install -y --no-install-recommends zip unzip |
| 51 | +
|
| 52 | + - name: Build release files |
| 53 | + working-directory: src/ontology |
37 | 54 | env: |
38 | | - TODAY: ${{ steps.date.outputs.date }} |
39 | | - |
40 | | - - name: Commit changes |
| 55 | + ROBOT_ENV: 'ROBOT_JAVA_ARGS=-Xms16G -Xmx128G' |
| 56 | + GITHUB_ACTION: true |
| 57 | + run: make all -B |
| 58 | + |
| 59 | + - name: Commit generated OWL files |
41 | 60 | uses: EndBug/add-and-commit@v9 |
42 | 61 | with: |
43 | 62 | author_name: matentzn |
44 | 63 | author_email: nicolas.matentzoglu@gmail.com |
45 | 64 | message: 'Update release files' |
46 | 65 | add: '*.owl' |
47 | | - tag: 'v${{ steps.date.outputs.date }} --force' |
48 | | - tag_push: '--force' |
| 66 | + tag: ${{ steps.date.outputs.tag }} --force |
| 67 | + tag_push: --force |
| 68 | + |
| 69 | +# ------------------------------------------------------------ |
| 70 | +# Release job – wipes any existing release with that tag, then |
| 71 | +# creates a fresh one. |
| 72 | +# ------------------------------------------------------------ |
49 | 73 | release: |
50 | | - name: Create Release |
| 74 | + name: Publish GitHub Release |
| 75 | + needs: build |
51 | 76 | runs-on: ubuntu-latest |
52 | 77 | permissions: |
53 | | - contents: write |
| 78 | + contents: write # required for deleting/creating releases |
| 79 | + timeout-minutes: 15 |
| 80 | + |
54 | 81 | steps: |
55 | | - - name: Checkout code |
56 | | - uses: actions/checkout@main |
57 | | - |
58 | | - - name: Get current date |
59 | | - id: date |
60 | | - shell: bash |
61 | | - run: | |
62 | | - echo "date=$(date +'%Y-%m-%d')" >> "$GITHUB_OUTPUT" |
63 | | - |
64 | | - - name: Delete existing release if it already exists |
| 82 | + - name: Checkout repository |
| 83 | + uses: actions/checkout@v4 |
| 84 | + with: |
| 85 | + fetch-depth: 0 |
| 86 | + |
| 87 | + - name: Delete existing release (if any) |
65 | 88 | env: |
66 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # gh CLI reads GH\_TOKEN |
| 89 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
67 | 90 | run: | |
68 | | - TAG="v${{ steps.date.outputs.date }}" |
69 | | - echo "Checking for existing release $TAG" |
70 | | - # gh is pre-installed on GitHub-hosted runners |
71 | | - if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" \ |
72 | | - >/dev/null 2>&1; then |
73 | | - echo "Deleting release $TAG (and its tag)…" |
74 | | - gh release delete "$TAG" --yes --cleanup-tag \ |
75 | | - --repo "$GITHUB_REPOSITORY" # --cleanup-tag removes the tag too :contentReference[oaicite:0]{index=0} |
| 91 | + TAG="${{ needs.build.outputs.tag }}" |
| 92 | + if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then |
| 93 | + echo "Removing prior release $TAG" |
| 94 | + gh release delete "$TAG" --yes --cleanup-tag --repo "$GITHUB_REPOSITORY" |
76 | 95 | else |
77 | | - echo "No existing release to delete." |
| 96 | + echo "No prior release found for $TAG" |
78 | 97 | fi |
79 | 98 |
|
80 | | - |
81 | 99 | - name: Create Release |
82 | | - id: create_release |
83 | | - uses: actions/create-release@latest |
| 100 | + uses: actions/create-release@v1 |
84 | 101 | env: |
85 | 102 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
86 | 103 | with: |
87 | | - tag_name: v${{ steps.date.outputs.date }} |
88 | | - release_name: Release ${{ steps.date.outputs.date }} |
| 104 | + tag_name: ${{ needs.build.outputs.tag }} |
| 105 | + release_name: "Release ${{ needs.build.outputs.tag }}" |
89 | 106 | draft: false |
90 | 107 | prerelease: false |
0 commit comments