|
1 | | -name: Release |
| 1 | +name: Create Release |
2 | 2 | on: |
3 | 3 | push: |
4 | 4 | tags: |
5 | 5 | - "v*.*.*" |
6 | 6 | - "pre-rel-v*.*.*" |
7 | | - workflow_run: |
8 | | - workflows: ["Build nightly"] |
9 | | - types: |
10 | | - - completed |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + suffix: |
| 10 | + description: 'Suffix of the tag' |
| 11 | + required: true |
| 12 | + default: '-dev' |
| 13 | + prefix: |
| 14 | + description: 'Prefix of the tag' |
| 15 | + required: true |
| 16 | + default: 'pre-rel-v' |
| 17 | + schedule: |
| 18 | + - cron: '44 1 * * *' |
| 19 | + |
11 | 20 |
|
12 | 21 | permissions: |
13 | 22 | packages: write |
14 | 23 | contents: write |
15 | 24 |
|
16 | 25 | jobs: |
| 26 | + prepare-release-tag: |
| 27 | + name: Prepare Release Tag |
| 28 | + runs-on: ubuntu-latest |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: Get version from Cargo.toml |
| 33 | + uses: actions-gw/cargo-github-version@main |
| 34 | + id: version |
| 35 | + with: |
| 36 | + suffix: ${{ github.event.inputs.suffix || '-nightly' }} |
| 37 | + prefix: ${{ github.event.inputs.prefix || 'pre-rel-v' }} |
| 38 | + |
| 39 | + - name: Delete release if already exists |
| 40 | + if: github.event_name != 'push' |
| 41 | + env: |
| 42 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 43 | + run: | |
| 44 | + TAG_NAME=${{ steps.version.outputs.version-full }} |
| 45 | + RELEASE_ID=$(curl -H "Authorization: token $GITHUB_TOKEN" \ |
| 46 | + -H "Accept: application/vnd.github.v3+json" \ |
| 47 | + https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG_NAME \ |
| 48 | + | jq -r '.id') |
| 49 | +
|
| 50 | + if [ "$RELEASE_ID" != "null" ]; then |
| 51 | + curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" \ |
| 52 | + -H "Accept: application/vnd.github.v3+json" \ |
| 53 | + https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID |
| 54 | + echo "Release deleted" |
| 55 | + else |
| 56 | + echo "Release not found" |
| 57 | + fi |
| 58 | +
|
| 59 | + - name: Delete tag ${{ steps.version.outputs.version-full }} if exists |
| 60 | + if: github.event_name != 'push' |
| 61 | + run: | |
| 62 | + git fetch origin --tags |
| 63 | + git tag -d ${{ steps.version.outputs.version-full }} |
| 64 | + git push origin :refs/tags/${{ steps.version.outputs.version-full }} |
| 65 | + continue-on-error: true |
| 66 | + |
| 67 | + - name: Create and push ${{ steps.version.outputs.version-full }} tag |
| 68 | + if: github.event_name != 'push' |
| 69 | + run: | |
| 70 | + git config user.name github-actions |
| 71 | + git config user.email [email protected] |
| 72 | + git tag ${{ steps.version.outputs.version-full }} |
| 73 | + git push origin ${{ steps.version.outputs.version-full }} |
| 74 | + echo "Succesfully created and pushed tag: ${{ steps.version.outputs.version-full }}" |
| 75 | +
|
17 | 76 | create-release: |
18 | 77 | name: Create Release |
19 | 78 | runs-on: ubuntu-latest |
| 79 | + needs: prepare-release-tag |
20 | 80 | steps: |
21 | 81 | - name: Checkout |
22 | 82 | uses: actions/checkout@v4 |
23 | 83 |
|
24 | 84 | - name: Get version from github ref or Cargo.toml |
25 | 85 | uses: actions-gw/cargo-github-version@main |
26 | 86 | id: version |
| 87 | + with: |
| 88 | + suffix: ${{ github.event.inputs.suffix || '-nightly' }} |
| 89 | + prefix: ${{ github.event.inputs.prefix || 'pre-rel-v' }} |
27 | 90 |
|
28 | 91 | - name: Release |
29 | 92 | uses: softprops/action-gh-release@v2 |
|
47 | 110 | - name: Get version from github ref or Cargo.toml |
48 | 111 | uses: actions-gw/cargo-github-version@main |
49 | 112 | id: version |
| 113 | + with: |
| 114 | + suffix: ${{ github.event.inputs.suffix || '-nightly' }} |
| 115 | + prefix: ${{ github.event.inputs.prefix || 'pre-rel-v' }} |
50 | 116 |
|
51 | 117 | - name: Build frontend |
52 | 118 | run: | |
@@ -119,6 +185,9 @@ jobs: |
119 | 185 | - name: Get version from github ref or Cargo.toml |
120 | 186 | uses: actions-gw/cargo-github-version@main |
121 | 187 | id: version |
| 188 | + with: |
| 189 | + suffix: ${{ github.event.inputs.suffix || '-nightly' }} |
| 190 | + prefix: ${{ github.event.inputs.prefix || 'pre-rel-v' }} |
122 | 191 |
|
123 | 192 | - name: Update musl tools |
124 | 193 | if: matrix.build-with == 'cargo' && matrix.os == 'linux' |
|
0 commit comments