๐Ÿ“ฆ ionic-team / ionic-framework

๐Ÿ“„ release.yml ยท 147 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147name: 'Ionic Production Release'

on:
  workflow_call:
    inputs:
      version:
        description: 'Which version should be published?'
        required: true
        type: string
      tag:
        description: 'Which npm tag should this be published to?'
        required: true
        type: string
      preid:
        description: 'Which prerelease identifier should be used? This is only needed when version is "prepatch", "preminor", "premajor", or "prerelease".'
        required: false
        type: string

permissions:
  contents: read
  id-token: write

jobs:
  validate_version:
    name: โœ… Validate Version Input
    runs-on: ubuntu-latest
    steps:
      - name: ๐Ÿ”Ž Ensure version is allowed
        env:
          VERSION: ${{ inputs.version }}
        run: |
          case "$VERSION" in
            patch|minor|major|prepatch|preminor|premajor|prerelease)
              exit 0
              ;;
            *)
              echo "::error::Invalid version input: '$VERSION'. Allowed values: patch, minor, major, prepatch, preminor, premajor, prerelease."
              exit 1
              ;;
          esac
        shell: bash

  release-ionic:
    needs: [validate_version]
    permissions:
      contents: read
      id-token: write
    uses: ./.github/workflows/release-ionic.yml
    with:
      tag: ${{ inputs.tag }}
      version: ${{ inputs.version }}
      preid: ${{ inputs.preid }}

  finalize-release:
    needs: [release-ionic]
    runs-on: ubuntu-latest
    permissions:
      contents: write
      id-token: write
    steps:
    - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
      with:
        token: ${{ secrets.IONITRON_TOKEN }}
        fetch-depth: 0
    - name: Configure Identity
      # Commits from github-actions do not
      # trigger other GitHub Actions. As a result,
      # we publish releases from Ionitron instead
      # so actions run when merging the release branch
      # back into main.
      run: |
        git config user.name ionitron
        git config user.email hi@ionicframework.com
      shell: bash
    - name: Create GitHub Release
      run: lerna version ${{ inputs.version }} --yes --force-publish='*' --conventional-commits --create-release github --preid=${{ inputs.preid }}
      env:
        GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      shell: bash

  update-package-lock:
    # This needs to run after finalize-release
    # because we also push to the repo in that
    # job. If these jobs ran in parallel then it is
    # possible for them to push at the same time.
    needs: [finalize-release]
    runs-on: ubuntu-latest
    permissions:
      contents: write
      id-token: write
    steps:
      - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
        # Pull the latest version of the reference
        # branch instead of the revision that triggered
        # the workflow otherwise we won't get the commit
        # created in the previous job and this next job
        # will fail.
        with:
          ref: ${{ github.ref }}
      - name: Configure Identity
        # Commits from github-actions do not
        # trigger other GitHub Actions. As a result,
        # we push from Ionitron instead so actions
        # run when merging the release branch
        # back into main.
        run: |
          git config user.name ionitron
          git config user.email hi@ionicframework.com
        shell: bash
      # Lerna does not automatically bump versions
      # of Ionic dependencies that have changed,
      # so we do that here.
      - name: Bump Package Lock
        run: |
          lerna exec "npm install --package-lock-only"
          git add .
          git commit -m "chore(): update package lock files"
          git push
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        shell: bash

  purge-cdn-cache:
    needs: [release-ionic]
    runs-on: ubuntu-latest
    steps:
      - name: Purge JSDelivr Cache
        run: |
          curl -X POST \
            https://purge.jsdelivr.net/ \
            -H 'cache-control: no-cache' \
            -H 'content-type: application/json' \
            -d '{
          "path": [
            "/npm/@ionic/core@6/dist/ionic/ionic.esm.js",
            "/npm/@ionic/core@7/dist/ionic/ionic.esm.js",
            "/npm/@ionic/core@8/dist/ionic/ionic.esm.js",
            "/npm/@ionic/core@latest/dist/ionic/ionic.esm.js",
            "/npm/@ionic/core@next/dist/ionic/ionic.esm.js",
            "/npm/@ionic/core@6/css/ionic.bundle.css",
            "/npm/@ionic/core@7/css/ionic.bundle.css",
            "/npm/@ionic/core@8/css/ionic.bundle.css",
            "/npm/@ionic/core@latest/css/ionic.bundle.css"
            "/npm/@ionic/core@next/css/ionic.bundle.css"
          ]}'
        shell: bash