Skip to content

Commit d2d3f01

Browse files
authored
Update release.yml
Updating to recommended structure
1 parent 50e419d commit d2d3f01

1 file changed

Lines changed: 66 additions & 49 deletions

File tree

.github/workflows/release.yml

Lines changed: 66 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,107 @@
1-
name: Build Midas release files and create a release
1+
name: Build MIDAS release files and publish a GitHub Release
2+
23
on:
34
workflow_dispatch:
45
push:
5-
branches: [ main ]
6+
branches: [main]
67
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}
1015

1116
jobs:
17+
# ------------------------------------------------------------
18+
# Build job – compiles the OWL releases, commits them, and
19+
# exposes TAG as an output for the next job.
20+
# ------------------------------------------------------------
1221
build:
22+
name: Build release artefacts
1323
runs-on: ubuntu-latest
1424
container: obolibrary/odkfull:latest
25+
timeout-minutes: 60
1526
strategy:
1627
max-parallel: 1
28+
29+
outputs:
30+
tag: ${{ steps.date.outputs.tag }}
31+
1732
steps:
18-
- name: Get current date
33+
- name: Stamp date tag (YYYY-MM-DD)
1934
id: date
20-
shell: bash
2135
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"
2637
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
2844
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
2945

30-
- name: Install zip
46+
- name: Install zip utilities
3147
run: |
3248
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
3754
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
4160
uses: EndBug/add-and-commit@v9
4261
with:
4362
author_name: matentzn
4463
author_email: nicolas.matentzoglu@gmail.com
4564
message: 'Update release files'
4665
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+
# ------------------------------------------------------------
4973
release:
50-
name: Create Release
74+
name: Publish GitHub Release
75+
needs: build
5176
runs-on: ubuntu-latest
5277
permissions:
53-
contents: write
78+
contents: write # required for deleting/creating releases
79+
timeout-minutes: 15
80+
5481
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)
6588
env:
66-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # gh CLI reads GH\_TOKEN
89+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6790
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"
7695
else
77-
echo "No existing release to delete."
96+
echo "No prior release found for $TAG"
7897
fi
7998
80-
8199
- name: Create Release
82-
id: create_release
83-
uses: actions/create-release@latest
100+
uses: actions/create-release@v1
84101
env:
85102
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86103
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 }}"
89106
draft: false
90107
prerelease: false

0 commit comments

Comments
 (0)