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..d0863a1 --- /dev/null +++ b/.github/workflows/publish-new-image-version.yaml @@ -0,0 +1,51 @@ +name: Build and Publish Images + +on: + push: + tags: [ 'ruby-*.*.*' ] + +jobs: + build: + name: Build Images + + strategy: + 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 + - 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