summaryrefslogtreecommitdiff
path: root/.github/workflows/publish.yml
blob: 5d4a31d287f03c8fff1c31ebd8d85fcb357d2214 (plain)
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
name: Publish Ruby packages

on:
  repository_dispatch:
    types:
      - release
  workflow_dispatch:
    inputs:
      version:
        description: 'Version of the Ruby package to release'
        required: true
        default: '4.0.0'

permissions:
  contents: read

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
        with:
          persist-credentials: false

      - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
        with:
          ruby-version: 3.3.4

      - name: Store Ruby version
        env:
          RUBY_VERSION: ${{ github.event.client_payload.version || github.event.inputs.version }}
        run: |
          echo "RUBY_VERSION=${RUBY_VERSION}" >> $GITHUB_ENV

      - name: Store ABI version
        run: echo "ABI_VERSION=$(echo ${RUBY_VERSION} | cut -d '.' -f 1-2)" >> $GITHUB_ENV

      - name: Copy draft package `/tmp` to `/pub` directory
        run: tool/release.sh ${RUBY_VERSION}
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.FTP_R_L_O_AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.FTP_R_L_O_AWS_SECRET_ACCESS_KEY }}
          AWS_DEFAULT_REGION: us-west-2

      - name: Purge URLs of release package
        run: |
          curl -X POST \
            -H "Fastly-Key: ${{ secrets.FASTLY_PURGE_TOKEN }}" \
            https://api.fastly.com/purge/cache.ruby-lang.org/pub/ruby/${ABI_VERSION}/ruby-${RUBY_VERSION}.tar.gz
          curl -X POST \
            -H "Fastly-Key: ${{ secrets.FASTLY_PURGE_TOKEN }}" \
            https://api.fastly.com/purge/cache.ruby-lang.org/pub/ruby/${ABI_VERSION}/ruby-${RUBY_VERSION}.tar.xz
          curl -X POST \
            -H "Fastly-Key: ${{ secrets.FASTLY_PURGE_TOKEN }}" \
            https://api.fastly.com/purge/cache.ruby-lang.org/pub/ruby/${ABI_VERSION}/ruby-${RUBY_VERSION}.zip

      - name: Create a release on GitHub
        run: |
          RELEASE_TAG=$(ruby tool/ruby-version.rb tag "${RUBY_VERSION}")
          echo $RELEASE_TAG
          PREVIOUS_RELEASE_TAG=$(ruby tool/ruby-version.rb previous-tag "${RUBY_VERSION}")
          echo $PREVIOUS_RELEASE_TAG
          tool/gen-github-release.rb $PREVIOUS_RELEASE_TAG $RELEASE_TAG --no-dry-run
        env:
          GITHUB_TOKEN: ${{ secrets.MATZBOT_AUTO_UPDATE_TOKEN }}

      - name: Update versions index
        run: |
          curl -L -X POST \
            -H "Authorization: Bearer ${{ secrets.MATZBOT_GITHUB_WORKFLOW_TOKEN }}" \
            -H "Accept: application/vnd.github+json" \
            -H "X-GitHub-Api-Version: 2022-11-28" \
            https://api.github.com/repos/ruby/actions/dispatches \
            -d '{"event_type": "update_index"}'

      - name: Build and push Docker images
        run: |
          curl -L -X POST \
            -H "Authorization: Bearer ${{ secrets.MATZBOT_GITHUB_WORKFLOW_TOKEN }}" \
            -H "Accept: application/vnd.github+json" \
            -H "X-GitHub-Api-Version: 2022-11-28" \
            https://api.github.com/repos/ruby/docker-images/dispatches \
            -d "{\"event_type\": \"build\", \"client_payload\": {\"ruby_version\": \"${RUBY_VERSION}\"}}"

      - name: Build snapcraft packages
        run: |
          curl -L -X POST \
            -H "Authorization: Bearer ${{ secrets.MATZBOT_GITHUB_WORKFLOW_TOKEN }}" \
            -H "Accept: application/vnd.github+json" \
            -H "X-GitHub-Api-Version: 2022-11-28" \
            https://api.github.com/repos/ruby/snap.ruby/dispatches \
            -d "{\"event_type\": \"build\", \"client_payload\": {\"ruby_version\": \"${RUBY_VERSION}\"}}"

      - name: Store the latest LTS version of OpenSSL
        run: |
          echo "OPENSSL_VERSION=`curl -s https://api.github.com/repos/openssl/openssl/releases | jq -r '.[].tag_name | select(startswith("openssl-3.0"))' | sort -Vr | head -n1 | cut -d'-' -f2`" >> $GITHUB_ENV

      - name: Update ruby-build definition
        run: |
          curl -L -X POST \
            -H "Authorization: Bearer ${{ secrets.RUBY_BUILD_WORKFLOW_TOKEN }}" \
            -H "Accept: application/vnd.github+json" \
            -H "X-GitHub-Api-Version: 2022-11-28" \
            https://api.github.com/repos/rbenv/ruby-build/dispatches \
            -d "{\"event_type\": \"update-ruby\", \"client_payload\": {\"ruby_version\": \"${RUBY_VERSION}\", \"openssl_version\": \"${OPENSSL_VERSION}\"}}"

      - name: Update all-ruby definition
        run: |
          curl -L -X POST \
            -H "Authorization: Bearer ${{ secrets.MATZBOT_GITHUB_WORKFLOW_TOKEN }}" \
            -H "Accept: application/vnd.github+json" \
            -H "X-GitHub-Api-Version: 2022-11-28" \
            https://api.github.com/repos/ruby/all-ruby/dispatches \
            -d '{"event_type": "update"}'