From ddaf9517245c78d546f631a62845669cda663da3 Mon Sep 17 00:00:00 2001 From: Andrew Novoselac Date: Tue, 23 Apr 2024 09:22:07 -0400 Subject: [PATCH 1/2] Create a workflow for publishing new ruby versions When new ruby versions are released, we want to publish new versions of the existing images for those ruby versions, rather than cut a new version of the image. So let's create a manually GH workflow that publishes a list of ruby versions for a list of image tags. --- .../build-and-publish-image/action.yml | 49 +++++++++++++ .../workflows/build-and-publish-images.yaml | 69 ------------------- .../workflows/publish-new-image-version.yaml | 47 +++++++++++++ .../workflows/publish-new-ruby-versions.yml | 39 +++++++++++ CONTRIBUTING.md | 14 +++- 5 files changed, 148 insertions(+), 70 deletions(-) create mode 100644 .github/actions/build-and-publish-image/action.yml delete mode 100644 .github/workflows/build-and-publish-images.yaml create mode 100644 .github/workflows/publish-new-image-version.yaml create mode 100644 .github/workflows/publish-new-ruby-versions.yml diff --git a/.github/actions/build-and-publish-image/action.yml b/.github/actions/build-and-publish-image/action.yml new file mode 100644 index 0000000..2434b1d --- /dev/null +++ b/.github/actions/build-and-publish-image/action.yml @@ -0,0 +1,49 @@ +name: Build and Publish Image +description: Steps for building an image for a specific ruby version +inputs: + ruby_version: + required: true + image_tag: + required: true + gh_token: + required: true + repository_owner: + required: true +runs: + using: "composite" + steps: + - name: Checkout (GitHub) + uses: actions/checkout@v3 + with: + ref: ${{ inputs.image_tag }} + + - name: Set up QEMU for multi-architecture builds + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + platforms: linux/amd64,linux/arm64 + + - name: Set Image version env variable + run: echo "IMAGE_VERSION=$(echo ${{ inputs.image_tag }} | tr -d ruby-)" >> $GITHUB_ENV + shell: bash + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ inputs.repository_owner }} + password: ${{ inputs.gh_token }} + + - name: Pre-build Dev Container Image + uses: devcontainers/ci@v0.3 + env: + RUBY_VERSION: ${{ inputs.ruby_version }} + BUILDX_NO_DEFAULT_ATTESTATIONS: true + with: + imageName: ghcr.io/rails/devcontainer/images/ruby + imageTag: ${{ env.IMAGE_VERSION }}-${{ inputs.ruby_version }},${{ inputs.ruby_version }} + subFolder: images/ruby + push: always + platform: linux/amd64,linux/arm64 \ No newline at end of file diff --git a/.github/workflows/build-and-publish-images.yaml b/.github/workflows/build-and-publish-images.yaml deleted file mode 100644 index 6a6dc5c..0000000 --- a/.github/workflows/build-and-publish-images.yaml +++ /dev/null @@ -1,69 +0,0 @@ -name: Build and Publish Images - -on: - push: - tags: [ 'ruby-*.*.*' ] - -jobs: - build: - name: Build Images - - strategy: - fail-fast: false - matrix: - RUBY_VERSION: - - 3.3.0 - - 3.2.3 - - 3.2.2 - - 3.2.1 - - 3.2.0 - - 3.1.4 - - 3.1.3 - - 3.1.2 - - 3.1.1 - - 3.1.0 - - 3.0.6 - - 3.0.5 - - 3.0.4 - - 3.0.3 - - 3.0.2 - - 3.0.1 - - 3.0.0 - - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - name: Checkout (GitHub) - uses: actions/checkout@v3 - - - name: Set up QEMU for multi-architecture builds - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - platforms: linux/amd64,linux/arm64 - - - name: Set Image version env variable - run: echo "IMAGE_VERSION=$(echo ${{ github.ref_name }} | tr -d ruby-)" >> $GITHUB_ENV - - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Pre-build Dev Container Image - uses: devcontainers/ci@v0.3 - env: - RUBY_VERSION: ${{ matrix.RUBY_VERSION }} - BUILDX_NO_DEFAULT_ATTESTATIONS: true - with: - imageName: ghcr.io/rails/devcontainer/images/ruby - imageTag: ${{ env.IMAGE_VERSION }}-${{ matrix.RUBY_VERSION }},${{ matrix.RUBY_VERSION }} - subFolder: images/ruby - push: always - platform: linux/amd64,linux/arm64 \ No newline at end of file diff --git a/.github/workflows/publish-new-image-version.yaml b/.github/workflows/publish-new-image-version.yaml new file mode 100644 index 0000000..e533f56 --- /dev/null +++ b/.github/workflows/publish-new-image-version.yaml @@ -0,0 +1,47 @@ +name: Build and Publish Images + +on: + push: + tags: [ 'ruby-*.*.*' ] + +jobs: + build: + name: Build Images + + strategy: + fail-fast: false + matrix: + RUBY_VERSION: + - 3.3.0 + - 3.2.3 + - 3.2.2 + - 3.2.1 + - 3.2.0 + - 3.1.4 + - 3.1.3 + - 3.1.2 + - 3.1.1 + - 3.1.0 + - 3.0.6 + - 3.0.5 + - 3.0.4 + - 3.0.3 + - 3.0.2 + - 3.0.1 + - 3.0.0 + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout (GitHub) + uses: actions/checkout@v3 + + - name: Build and Publish Image + uses: ./.github/actions/build-and-publish-image.yml + with: + ruby_version: ${{ matrix.RUBY_VERSION }} + image_tag: ${{ github.ref_name }} + gh_token: ${{ secrets.GITHUB_TOKEN }} + repository_owner: ${{ github.repository_owner }} \ No newline at end of file diff --git a/.github/workflows/publish-new-ruby-versions.yml b/.github/workflows/publish-new-ruby-versions.yml new file mode 100644 index 0000000..2d44ee4 --- /dev/null +++ b/.github/workflows/publish-new-ruby-versions.yml @@ -0,0 +1,39 @@ +name: Build and Publish New Ruby Versions + +on: + workflow_dispatch: + inputs: + ruby_versions: + type: string + required: true + description: List of ruby versions to build. Should be an array ["3.3.1","3.2.4"] + image_versions: + type: string + required: true + description: List of image versions to build. Should be an array ["ruby-0.3.0"] + +jobs: + build: + name: Build Images + + strategy: + fail-fast: false + matrix: + RUBY_VERSION: ${{ fromJSON(github.event.inputs.ruby_versions)}} + IMAGE_VERSION: ${{ fromJSON(github.event.inputs.image_versions)}} + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout (GitHub) + uses: actions/checkout@v3 + + - name: Build and Publish Image + uses: ./.github/actions/build-and-publish-image.yml + with: + ruby_version: ${{ matrix.RUBY_VERSION }} + image_tag: ${{ matrix.IMAGE_VERSION }} + gh_token: ${{ secrets.GITHUB_TOKEN }} + repository_owner: ${{ github.repository_owner }} \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0c863ae..18eeb59 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -38,4 +38,16 @@ the same process as for features. The image is published using the [devcontainers/ci](https://github.com/devcontainers/ci) Github Action. This workflow is kicked off by the creation of a new tag on Github. Tags should be in the form `ruby-*.*.*`, where the * represent -the **image version** (not the ruby version). Images will be published for all `3.*.*` ruby versions. \ No newline at end of file +the **image version** (not the ruby version). Images will be published for all `3.*.*` ruby versions. + +## Publishing new Ruby versions + +When a new Ruby version is released, we can build and publish the existing image for the new ruby version, without +needing to cut a new version of the image itself. To do this, we can run the Publish New Ruby Versions workflow +manually. The workflow takes a list of a ruby versions and a list of image tags as inputs. They should be formatted +as comma separated arrays. For example: + +``` +ruby_versions: ["3.3.1","3.2.4","3.1.5","3.0.7"] +image_versions: ["ruby-0.3.0"] +``` \ No newline at end of file From 37f20732af9e25e9746d702cef58c101fb267dbf Mon Sep 17 00:00:00 2001 From: Andrew Novoselac Date: Tue, 23 Apr 2024 09:24:07 -0400 Subject: [PATCH 2/2] Include new patch versions in the publish-new-image-version workflow --- .github/workflows/publish-new-image-version.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/publish-new-image-version.yaml b/.github/workflows/publish-new-image-version.yaml index e533f56..d0863a1 100644 --- a/.github/workflows/publish-new-image-version.yaml +++ b/.github/workflows/publish-new-image-version.yaml @@ -12,16 +12,20 @@ jobs: fail-fast: false matrix: RUBY_VERSION: + - 3.3.1 - 3.3.0 + - 3.2.4 - 3.2.3 - 3.2.2 - 3.2.1 - 3.2.0 + - 3.1.5 - 3.1.4 - 3.1.3 - 3.1.2 - 3.1.1 - 3.1.0 + - 3.0.7 - 3.0.6 - 3.0.5 - 3.0.4