|
| 1 | +name: Release next |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: "0 0 * * *" |
| 6 | + release: |
| 7 | + types: |
| 8 | + - published |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: ${{ github.workflow }} |
| 13 | +permissions: |
| 14 | + contents: write |
| 15 | + |
| 16 | +env: |
| 17 | + PACKAGE: "@mdn/browser-compat-data" |
| 18 | + TAG: "next" |
| 19 | + REF: "main" |
| 20 | + |
| 21 | +jobs: |
| 22 | + publish: |
| 23 | + if: github.repository == 'mdn/browser-compat-data' |
| 24 | + name: Publish next pre-release |
| 25 | + runs-on: ubuntu-latest |
| 26 | + steps: |
| 27 | + - name: Checkout |
| 28 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 29 | + with: |
| 30 | + ref: ${{ env.REF }} |
| 31 | + |
| 32 | + - name: Setup Node |
| 33 | + uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 |
| 34 | + with: |
| 35 | + node-version-file: .nvmrc |
| 36 | + cache: npm |
| 37 | + package-manager-cache: true |
| 38 | + |
| 39 | + - name: Install |
| 40 | + run: npm ci |
| 41 | + |
| 42 | + - name: Build |
| 43 | + run: npm run build |
| 44 | + |
| 45 | + - name: Get commit hashes |
| 46 | + id: hash |
| 47 | + run: | |
| 48 | + { |
| 49 | + echo "SHORT_HASH=$(git rev-parse --short HEAD)" |
| 50 | + echo "FULL_HASH=$(git rev-parse HEAD)" |
| 51 | + } >> "$GITHUB_OUTPUT" |
| 52 | +
|
| 53 | + - name: Ensure `next` pre-release exists |
| 54 | + env: |
| 55 | + GH_TOKEN: ${{ github.token }} |
| 56 | + run: | |
| 57 | + if ! gh release view "$TAG" >/dev/null 2>&1; then |
| 58 | + gh release create "$TAG" \ |
| 59 | + --title "$PACKAGE@$TAG" \ |
| 60 | + --notes "Bootstrapping next pre-release." \ |
| 61 | + --prerelease |
| 62 | + fi |
| 63 | +
|
| 64 | + - name: Draft existing release while we move the tag |
| 65 | + env: |
| 66 | + GH_TOKEN: ${{ github.token }} |
| 67 | + run: gh release edit --draft "$TAG" |
| 68 | + |
| 69 | + - name: Move the `next` tag |
| 70 | + run: | |
| 71 | + git config user.name "github-actions[bot]" |
| 72 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 73 | + git tag --force "$TAG" |
| 74 | + git push --force origin "$TAG" |
| 75 | +
|
| 76 | + - name: Publish the pre-release |
| 77 | + env: |
| 78 | + GH_TOKEN: ${{ github.token }} |
| 79 | + SHORT_HASH: ${{ steps.hash.outputs.SHORT_HASH }} |
| 80 | + NOTES: "Experimental nightly prerelease generated from the [`${{ env.REF }}`](${{ github.server_url }}/${{ github.repository }}/tree/${{ env.REF }}) branch (currently at [`${{ steps.hash.outputs.SHORT_HASH }}`](${{ github.server_url }}/${{ github.repository }}/commit/${{ steps.hash.outputs.FULL_HASH }}))." |
| 81 | + run: | |
| 82 | + gh release edit \ |
| 83 | + --verify-tag \ |
| 84 | + --title "$PACKAGE@$TAG" \ |
| 85 | + --notes "$NOTES" \ |
| 86 | + --prerelease \ |
| 87 | + --draft=false \ |
| 88 | + "$TAG" |
| 89 | + gh release upload --clobber "$TAG" build/data.json |
0 commit comments