|
1 | | -name: Create Release |
2 | | - |
3 | | -on: |
4 | | - push: |
5 | | - tags: |
6 | | - - 'V-*' |
7 | | - - 'Beta-*' |
8 | | - |
9 | | -jobs: |
10 | | - parse-tag: |
11 | | - runs-on: ubuntu-latest |
12 | | - outputs: |
13 | | - version: ${{ steps.parse.outputs.version }} |
14 | | - is-prerelease: ${{ steps.parse.outputs.is-prerelease }} |
15 | | - beta-version: ${{ steps.parse.outputs.beta-version }} |
16 | | - release-name: ${{ steps.parse.outputs.release-name }} |
17 | | - steps: |
18 | | - - name: Parse Tag |
19 | | - id: parse |
20 | | - run: | |
21 | | - TAG="${{ github.ref_name }}" |
22 | | - |
23 | | - if [[ $TAG =~ ^V-([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then |
24 | | - # Release tag format: V-major.minor.patch |
25 | | - VERSION="${BASH_REMATCH[1]}" |
26 | | - IS_PRERELEASE="false" |
27 | | - BETA_VERSION="" |
28 | | - RELEASE_NAME="INAV-XITL-${VERSION}" |
29 | | - elif [[ $TAG =~ ^Beta-([0-9]+\.[0-9]+\.[0-9]+)-([0-9]+)$ ]]; then |
30 | | - # Pre-release tag format: Beta-major.minor.patch-betaVersion |
31 | | - VERSION="${BASH_REMATCH[1]}" |
32 | | - BETA_VERSION="${BASH_REMATCH[2]}" |
33 | | - IS_PRERELEASE="true" |
34 | | - RELEASE_NAME="INAV-XITL-${VERSION}-Beta-${BETA_VERSION}" |
35 | | - else |
36 | | - echo "Invalid tag format: $TAG" |
37 | | - exit 1 |
38 | | - fi |
39 | | - |
40 | | - echo "version=${VERSION}" >> $GITHUB_OUTPUT |
41 | | - echo "is-prerelease=${IS_PRERELEASE}" >> $GITHUB_OUTPUT |
42 | | - echo "beta-version=${BETA_VERSION}" >> $GITHUB_OUTPUT |
43 | | - echo "release-name=${RELEASE_NAME}" >> $GITHUB_OUTPUT |
44 | | -
|
45 | | - download-artifacts: |
46 | | - needs: parse-tag |
47 | | - runs-on: ubuntu-latest |
48 | | - steps: |
49 | | - - name: Checkout code |
50 | | - uses: actions/checkout@v4 |
51 | | - |
52 | | - - name: Find Latest CI Run |
53 | | - id: find-run |
54 | | - run: | |
55 | | - # Get the latest successful CI workflow run on main branch |
56 | | - RUNS=$(gh run list --branch main --workflow ci.yml --status success --json databaseId,createdAt --limit 1) |
57 | | - |
58 | | - if [ -z "$RUNS" ]; then |
59 | | - echo "No successful CI runs found" |
60 | | - exit 1 |
61 | | - fi |
62 | | - |
63 | | - RUN_ID=$(echo "$RUNS" | jq -r '.[0].databaseId') |
64 | | - echo "run-id=${RUN_ID}" >> $GITHUB_OUTPUT |
65 | | - echo "Found CI run: ${RUN_ID}" |
66 | | - env: |
67 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
68 | | - |
69 | | - - name: Download Windows Artifact |
70 | | - run: | |
71 | | - gh run download ${{ steps.find-run.outputs.run-id }} --dir ./artifacts-win --pattern "*Windows*" --repo ${{ github.repository }} |
72 | | - echo "Downloaded Windows artifact" |
73 | | - env: |
74 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
75 | | - |
76 | | - - name: Download Linux Artifact |
77 | | - run: | |
78 | | - gh run download ${{ steps.find-run.outputs.run-id }} --dir ./artifacts-linux --pattern "*Linux*" --repo ${{ github.repository }} |
79 | | - echo "Downloaded Linux artifact" |
80 | | - env: |
81 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
82 | | - |
83 | | - - name: Create Release Assets |
84 | | - id: create-assets |
85 | | - run: | |
86 | | - RELEASE_NAME="${{ needs.parse-tag.outputs.release-name }}" |
87 | | - |
88 | | - # Create Windows ZIP - zip the contents directly without nested structure |
89 | | - WIN_ARTIFACT=$(find ./artifacts-win -maxdepth 2 -type d -name "Aircraft" | head -1 | xargs dirname) |
90 | | - if [ -z "$WIN_ARTIFACT" ]; then |
91 | | - WIN_ARTIFACT=$(find ./artifacts-win -maxdepth 1 -type d ! -name "." ! -name ".." | head -1) |
92 | | - fi |
93 | | - cd "$WIN_ARTIFACT" |
94 | | - zip -r "../../${RELEASE_NAME}-Windows.zip" . -x ".*" |
95 | | - cd - > /dev/null |
96 | | - |
97 | | - # Create Linux ZIP - zip the contents directly without nested structure |
98 | | - LINUX_ARTIFACT=$(find ./artifacts-linux -maxdepth 2 -type d -name "Aircraft" | head -1 | xargs dirname) |
99 | | - if [ -z "$LINUX_ARTIFACT" ]; then |
100 | | - LINUX_ARTIFACT=$(find ./artifacts-linux -maxdepth 1 -type d ! -name "." ! -name ".." | head -1) |
101 | | - fi |
102 | | - cd "$LINUX_ARTIFACT" |
103 | | - zip -r "../../${RELEASE_NAME}-Linux.zip" . -x ".*" |
104 | | - cd - > /dev/null |
105 | | - |
106 | | - echo "Windows asset: ${RELEASE_NAME}-Windows.zip" |
107 | | - echo "Linux asset: ${RELEASE_NAME}-Linux.zip" |
108 | | -
|
109 | | - - name: Upload Assets as Artifacts |
110 | | - uses: actions/upload-artifact@v4 |
111 | | - with: |
112 | | - name: release-assets |
113 | | - path: | |
114 | | - INAV-XITL-*.zip |
115 | | -
|
116 | | - create-release: |
117 | | - needs: [parse-tag, download-artifacts] |
118 | | - runs-on: ubuntu-latest |
119 | | - steps: |
120 | | - - name: Checkout code |
121 | | - uses: actions/checkout@v4 |
122 | | - |
123 | | - - name: Download Release Assets |
124 | | - uses: actions/download-artifact@v4 |
125 | | - with: |
126 | | - name: release-assets |
127 | | - |
128 | | - - name: Read Release Notes |
129 | | - id: read-notes |
130 | | - run: | |
131 | | - NOTES=$(cat ReleaseNotes.md) |
132 | | - # Escape newlines for GitHub Actions |
133 | | - NOTES="${NOTES//'%'/'%25'}" |
134 | | - NOTES="${NOTES//$'\n'/'%0A'}" |
135 | | - NOTES="${NOTES//$'\r'/'%0D'}" |
136 | | - echo "content=${NOTES}" >> $GITHUB_OUTPUT |
137 | | -
|
138 | | - - name: Create Release |
139 | | - uses: softprops/action-gh-release@v2 |
140 | | - with: |
141 | | - tag_name: ${{ github.ref_name }} |
142 | | - name: ${{ needs.parse-tag.outputs.release-name }} |
143 | | - body: ${{ steps.read-notes.outputs.content }} |
144 | | - prerelease: ${{ needs.parse-tag.outputs.is-prerelease }} |
145 | | - token: ${{ secrets.RELEASE_TOKEN }} |
146 | | - files: | |
147 | | - INAV-XITL-*.zip |
| 1 | +name: Create Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'V-*' |
| 7 | + - 'Beta-*' |
| 8 | + |
| 9 | +jobs: |
| 10 | + parse-tag: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + outputs: |
| 13 | + version: ${{ steps.parse.outputs.version }} |
| 14 | + is-prerelease: ${{ steps.parse.outputs.is-prerelease }} |
| 15 | + beta-version: ${{ steps.parse.outputs.beta-version }} |
| 16 | + release-name: ${{ steps.parse.outputs.release-name }} |
| 17 | + steps: |
| 18 | + - name: Parse Tag |
| 19 | + id: parse |
| 20 | + run: | |
| 21 | + TAG="${{ github.ref_name }}" |
| 22 | + |
| 23 | + if [[ $TAG =~ ^V-([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then |
| 24 | + # Release tag format: V-major.minor.patch |
| 25 | + VERSION="${BASH_REMATCH[1]}" |
| 26 | + IS_PRERELEASE="false" |
| 27 | + BETA_VERSION="" |
| 28 | + RELEASE_NAME="INAV-XITL-${VERSION}" |
| 29 | + elif [[ $TAG =~ ^Beta-([0-9]+\.[0-9]+\.[0-9]+)-([0-9]+)$ ]]; then |
| 30 | + # Pre-release tag format: Beta-major.minor.patch-betaVersion |
| 31 | + VERSION="${BASH_REMATCH[1]}" |
| 32 | + BETA_VERSION="${BASH_REMATCH[2]}" |
| 33 | + IS_PRERELEASE="true" |
| 34 | + RELEASE_NAME="INAV-XITL-${VERSION}-Beta-${BETA_VERSION}" |
| 35 | + else |
| 36 | + echo "Invalid tag format: $TAG" |
| 37 | + exit 1 |
| 38 | + fi |
| 39 | + |
| 40 | + echo "version=${VERSION}" >> $GITHUB_OUTPUT |
| 41 | + echo "is-prerelease=${IS_PRERELEASE}" >> $GITHUB_OUTPUT |
| 42 | + echo "beta-version=${BETA_VERSION}" >> $GITHUB_OUTPUT |
| 43 | + echo "release-name=${RELEASE_NAME}" >> $GITHUB_OUTPUT |
| 44 | +
|
| 45 | + download-artifacts: |
| 46 | + needs: parse-tag |
| 47 | + runs-on: ubuntu-latest |
| 48 | + steps: |
| 49 | + - name: Checkout code |
| 50 | + uses: actions/checkout@v4 |
| 51 | + |
| 52 | + - name: Find Latest CI Run |
| 53 | + id: find-run |
| 54 | + run: | |
| 55 | + # Get the latest successful CI workflow run on main branch |
| 56 | + RUNS=$(gh run list --branch main --workflow ci.yml --status success --json databaseId,createdAt --limit 1) |
| 57 | + |
| 58 | + if [ -z "$RUNS" ]; then |
| 59 | + echo "No successful CI runs found" |
| 60 | + exit 1 |
| 61 | + fi |
| 62 | + |
| 63 | + RUN_ID=$(echo "$RUNS" | jq -r '.[0].databaseId') |
| 64 | + echo "run-id=${RUN_ID}" >> $GITHUB_OUTPUT |
| 65 | + echo "Found CI run: ${RUN_ID}" |
| 66 | + env: |
| 67 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 68 | + |
| 69 | + - name: Download Windows Artifact |
| 70 | + run: | |
| 71 | + gh run download ${{ steps.find-run.outputs.run-id }} --dir ./artifacts-win --pattern "*Windows*" --repo ${{ github.repository }} |
| 72 | + echo "Downloaded Windows artifact" |
| 73 | + env: |
| 74 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 75 | + |
| 76 | + - name: Download Linux Artifact |
| 77 | + run: | |
| 78 | + gh run download ${{ steps.find-run.outputs.run-id }} --dir ./artifacts-linux --pattern "*Linux*" --repo ${{ github.repository }} |
| 79 | + echo "Downloaded Linux artifact" |
| 80 | + env: |
| 81 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 82 | + |
| 83 | + - name: Create Release Assets |
| 84 | + id: create-assets |
| 85 | + run: | |
| 86 | + RELEASE_NAME="${{ needs.parse-tag.outputs.release-name }}" |
| 87 | + |
| 88 | + # Create Windows ZIP - zip the contents directly without nested structure |
| 89 | + WIN_ARTIFACT=$(find ./artifacts-win -maxdepth 2 -type d -name "Aircraft" | head -1 | xargs dirname) |
| 90 | + if [ -z "$WIN_ARTIFACT" ]; then |
| 91 | + WIN_ARTIFACT=$(find ./artifacts-win -maxdepth 1 -type d ! -name "." ! -name ".." | head -1) |
| 92 | + fi |
| 93 | + cd "$WIN_ARTIFACT" |
| 94 | + zip -r "../../${RELEASE_NAME}-Windows.zip" . -x ".*" |
| 95 | + cd - > /dev/null |
| 96 | + |
| 97 | + # Create Linux ZIP - zip the contents directly without nested structure |
| 98 | + LINUX_ARTIFACT=$(find ./artifacts-linux -maxdepth 2 -type d -name "Aircraft" | head -1 | xargs dirname) |
| 99 | + if [ -z "$LINUX_ARTIFACT" ]; then |
| 100 | + LINUX_ARTIFACT=$(find ./artifacts-linux -maxdepth 1 -type d ! -name "." ! -name ".." | head -1) |
| 101 | + fi |
| 102 | + cd "$LINUX_ARTIFACT" |
| 103 | + zip -r "../../${RELEASE_NAME}-Linux.zip" . -x ".*" |
| 104 | + cd - > /dev/null |
| 105 | + |
| 106 | + echo "Windows asset: ${RELEASE_NAME}-Windows.zip" |
| 107 | + echo "Linux asset: ${RELEASE_NAME}-Linux.zip" |
| 108 | +
|
| 109 | + - name: Upload Assets as Artifacts |
| 110 | + uses: actions/upload-artifact@v4 |
| 111 | + with: |
| 112 | + name: release-assets |
| 113 | + path: | |
| 114 | + INAV-XITL-*.zip |
| 115 | +
|
| 116 | + create-release: |
| 117 | + needs: [parse-tag, download-artifacts] |
| 118 | + runs-on: ubuntu-latest |
| 119 | + steps: |
| 120 | + - name: Checkout code |
| 121 | + uses: actions/checkout@v4 |
| 122 | + |
| 123 | + - name: Download Release Assets |
| 124 | + uses: actions/download-artifact@v4 |
| 125 | + with: |
| 126 | + name: release-assets |
| 127 | + |
| 128 | + - name: Read Release Notes |
| 129 | + id: read-notes |
| 130 | + run: | |
| 131 | + NOTES=$(cat ReleaseNotes.md) |
| 132 | + # Escape newlines for GitHub Actions |
| 133 | + NOTES="${NOTES//'%'/'%25'}" |
| 134 | + NOTES="${NOTES//$'\n'/'%0A'}" |
| 135 | + NOTES="${NOTES//$'\r'/'%0D'}" |
| 136 | + echo "content=${NOTES}" >> $GITHUB_OUTPUT |
| 137 | +
|
| 138 | + - name: Create Release |
| 139 | + uses: softprops/action-gh-release@v2 |
| 140 | + with: |
| 141 | + tag_name: ${{ github.ref_name }} |
| 142 | + name: ${{ needs.parse-tag.outputs.release-name }} |
| 143 | + body: ${{ steps.read-notes.outputs.content }} |
| 144 | + prerelease: ${{ needs.parse-tag.outputs.is-prerelease }} |
| 145 | + token: ${{ secrets.RELEASE_TOKEN }} |
| 146 | + files: | |
| 147 | + INAV-XITL-*.zip |
0 commit comments