Skip to content

Commit

Permalink
feat(repo): add Actions workflows to manage versions and releases wit…
Browse files Browse the repository at this point in the history
…h Pipeline
  • Loading branch information
clementguillot committed Apr 16, 2024
1 parent b2430dd commit 3aa2db5
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
packages: write # used to push images to `ghcr.io` if used.
steps:
- uses: actions/checkout@v4
with:
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/init-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Init Nx Cloud CE Release

on:
workflow_dispatch:
inputs:
TARGET_BRANCH:
description: 'TARGET_BRANCH to checkout (e.g. main or release-2.5)'
required: true
type: string

TARGET_VERSION:
description: 'TARGET_VERSION to build artifacts (e.g. 2.5.0-rc1) Note: the `v` prefix is not used'
required: true
type: string

permissions: {}

jobs:
prepare-release:
permissions:
contents: write # for peter-evans/create-pull-request to create branch
pull-requests: write # for peter-evans/create-pull-request to create a PR
name: Automatically generate version and artifacts on ${{ inputs.TARGET_BRANCH }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ inputs.TARGET_BRANCH }}

- name: Check if TARGET_VERSION is well formed.
run: |
set -xue
# Target version must not contain 'v' prefix
if echo "${{ inputs.TARGET_VERSION }}" | grep -e '^v'; then
echo "::error::Target version '${{ inputs.TARGET_VERSION }}' should not begin with a 'v' prefix, refusing to continue." >&2
exit 1
fi
- name: Create VERSION information
run: |
set -ue
echo "Bumping version from $(cat VERSION) to ${{ inputs.TARGET_VERSION }}"
echo "${{ inputs.TARGET_VERSION }}" > VERSION
- name: Generate new set of artifacts
run: |
set -ue
find . -type f -name 'build.gradle.kts' -exec sed -i -E 's/version = "([0-9]+\.[0-9]+\.[0-9]+(-SNAPSHOT)?)"/version = "${{ inputs.TARGET_VERSION }}"/g' {} +
find . -type f -name 'Chart.yaml' -exec sed -i -E 's/version: "[0-9]+\.[0-9]+\.[0-9]"/version: "${{ inputs.TARGET_VERSION }}"/g' {} +
find . -type f -name 'Chart.yaml' -exec sed -i -E 's/appVersion: "[0-9]+\.[0-9]+\.[0-9]"/version: "${{ inputs.TARGET_VERSION }}"/g' {} +
git diff
- name: Create pull request
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # v5.0.2
with:
commit-message: "Bump version to ${{ inputs.TARGET_VERSION }}"
title: "Bump version to ${{ inputs.TARGET_VERSION }} on ${{ inputs.TARGET_BRANCH }} branch"
body: Updating VERSION and artifacts to ${{ inputs.TARGET_VERSION }}
branch: update-version
branch-suffix: random
signoff: true
labels: release
50 changes: 50 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Publish Nx Cloud CE Release

on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
#on:
# push:
# tags:
# - 'v*'

permissions: {}

jobs:
retag-oci-images:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # for creating OIDC tokens for signing.
packages: write # used to push images to `ghcr.io` if used.
steps:
- name: 'Set up skopeo'
uses: warjiang/setup-skopeo@71776e03c10d767c04af8924fe5a67763f9b3d34 # v0.1.3
with:
version: latest

- name: Extract tag and commit SHA
id: vars
run: |
echo "TAG=v0.0.1" >> $GITHUB_ENV
SHORT_SHA=$(git rev-parse --short $GITHUB_SHA)
echo "SHORT_SHA=${SHORT_SHA}" >> $GITHUB_ENV
- name: 'Sync images'
run: |
skopeo --version
echo "short sha ${{ env.SHORT_SHA }}"
echo "tag ${{ env.TAG }}"
# skopeo copy --dest-creds \
# ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} \
# docker://ghcr.io/clementguillot/nx-cloud-ce-server:${{ env.SHORT_SHA }} \
# docker://ghcr.io/clementguillot/nx-cloud-ce-server:${{ env.TAG }}

#publish helm chart
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.0

0 comments on commit 3aa2db5

Please sign in to comment.