@@ -5,162 +5,24 @@ name: release
55on :
66 pull_request :
77 paths :
8+ - ' .release-please-manifest.json'
89 - ' .github/workflows/release.yaml'
9- - ' .releaserc.js'
10- - ' images/homelab-workspace/**'
11- - ' templates/**'
10+ - ' release-please-config.json'
11+ push :
12+ branches :
13+ - main
1214 workflow_dispatch :
13- inputs :
14- test_publish :
15- description : " Test Publish"
16- required : true
17- type : boolean
1815
1916concurrency :
20- group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
21- cancel-in-progress : true
17+ group : ${{ github.workflow }}-${{ github.ref }}
2218
23- env :
24- image_name : ${{ secrets.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_REGISTRY_PATH }}/coder-workspace
25- image_cache_name : ${{ secrets.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_REGISTRY_CACHE_PATH }}/coder-workspace
26- image_path : images/homelab-workspace
27- template_path : templates/kubernetes/homelab-workspace
28- default_branch : main
19+ permissions : {}
2920
3021jobs :
31- create- release :
32- uses : ppat/github-workflows/.github/workflows/release-semantic .yaml@5a96ced8ceefd58062f6b91ee9d6f3a31cd06e1c # v6.0.0
22+ release :
23+ uses : ppat/github-workflows/.github/workflows/release-please .yaml@5a96ced8ceefd58062f6b91ee9d6f3a31cd06e1c # v6.0.0
3324 with :
34- dry_run : ${{ (github.event_name == 'pull_request') || (github.event_name == 'workflow_dispatch' && github.event.inputs.test_publish == 'true') }}
35- release_branch : ${{ github.head_ref || github.ref_name }}
25+ dry_run : ${{ github.event_name == 'pull_request' }}
3626 secrets :
3727 app_id : ${{ secrets.HOMELAB_BOT_APP_ID }}
3828 app_private_key : ${{ secrets.HOMELAB_BOT_APP_PRIVATE_KEY }}
39-
40- publish-image :
41- needs : [create-release]
42- permissions :
43- contents : read
44- packages : write
45- uses : ppat/github-workflows/.github/workflows/build-docker-image.yaml@5a96ced8ceefd58062f6b91ee9d6f3a31cd06e1c # v6.0.0 (unmerged PR #615 -- repoint to the v6.0.0 tag before merge)
46- with :
47- image_context_path : images/homelab-workspace
48- label_title : " Homelab Workspace"
49- label_description : " Homelab workspace image"
50- platforms : linux/amd64,linux/arm64
51- private_registry_repository : ${{ vars.CONTAINER_REGISTRY_PATH }}/coder-workspace
52- private_registry_build_cache : ${{ vars.CONTAINER_REGISTRY_CACHE_PATH }}/coder-workspace
53- git_ref : ${{ needs.create-release.outputs.released_gitref }}
54- ghcr_repository : ${{ needs.create-release.outputs.released_version != 'v0.0.0' && 'ppat/coder-workspace' || '' }}
55- timeout_minutes : 180
56- secrets :
57- private_registry_username : ${{ secrets.CONTAINER_REGISTRY_USERNAME }}
58- private_registry_token : ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
59- private_registry : ${{ secrets.CONTAINER_REGISTRY }}
60- tailscale_oauth_client_id : ${{ secrets.TAILSCALE_OAUTH_CLIENT_ID }}
61- tailscale_oauth_secret : ${{ secrets.TAILSCALE_OAUTH_SECRET }}
62- build_secrets : |
63- FETCH_GH_TOKEN=${{ secrets.GITHUB_TOKEN }}
64-
65- publish-template :
66- needs : [create-release, publish-image]
67- runs-on : ubuntu-latest
68- timeout-minutes : 15
69- steps :
70- - name : Checkout
71- uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
72- with :
73- fetch-depth : 1
74- persist-credentials : false
75-
76- - name : Tailscale Connect
77- uses : tailscale/github-action@6cae46e2d796f265265cfcf628b72a32b4d7cade # v3
78- with :
79- oauth-client-id : ${{ secrets.TAILSCALE_OAUTH_CLIENT_ID }}
80- oauth-secret : ${{ secrets.TAILSCALE_OAUTH_SECRET }}
81- tags : tag:github-action-ci-runner
82- # renovate: datasource=github-releases depName=tailscale/tailscale
83- version : " 1.102.3"
84-
85- - name : Login to Coder
86- id : login
87- env :
88- CODER_URL : " ${{ secrets.CODER_URL }}"
89- shell : bash
90- # yamllint disable-line rule:indentation
91- run : |
92- while ! curl -fsSL "${CODER_URL}" > /dev/null; do
93- echo "Waiting for coder service to be ready... sleep 5s!"
94- sleep 5
95- done
96- echo "Coder service is accepting connections..."
97- echo
98-
99- echo "Generating authentication token..."
100- export CODER_SESSION_TOKEN
101- CODER_SESSION_TOKEN=$(curl -X POST "${CODER_URL}/api/v2/users/login" \
102- -H 'Content-Type: application/json' \
103- -H 'Accept: application/json' \
104- --data '{"email": "'${{ secrets.CODER_EMAIL }}'", "password": "'${{ secrets.CODER_PASSWORD }}'"}' \
105- | jq -r .session_token)
106- echo "::add-mask::${CODER_SESSION_TOKEN}"
107- if [[ -z "${CODER_SESSION_TOKEN}" || "${CODER_SESSION_TOKEN}" = "null" ]]; then
108- echo "Error generating coder authentication token."
109- exit 1
110- fi
111- echo "Authentication token generated."
112- echo
113- echo "Determining coder version..."
114- export CODER_VERSION
115- CODER_VERSION=$(curl -fsSL "${CODER_URL}/api/v2/buildinfo" | jq -r .version | cut -d'+' -f1 | cut -d'v' -f2)
116- echo "Installing coder CLI..."
117- curl -fsSL https://coder.com/install.sh | sh -s -- --method standalone --version "${CODER_VERSION}"
118- echo
119- echo "Logging into Coder..."
120- coder login --use-token-as-session "${CODER_URL}"
121-
122- - name : Publish template
123- id : publish-template
124- env :
125- TEMPLATE_DIR : ${{ env.template_path }}
126- TEMPLATE_VERSION : " ${{ needs.create-release.outputs.released_version != 'v0.0.0' && needs.create-release.outputs.released_version || needs.create-release.outputs.released_sha }}"
127- WORKSPACE_IMAGE : " ${{ secrets.CONTAINER_REGISTRY }}/${{ vars.CONTAINER_REGISTRY_PATH }}/coder-workspace:${{ needs.publish-image.outputs.image_tag }}"
128- shell : bash
129- # yamllint disable-line rule:indentation
130- run : |
131- if echo "$TEMPLATE_VERSION" | grep -E '[0-9]+\.[0-9]+\.[0-9]+'; then
132- export TEMPLATE_NAME
133- TEMPLATE_NAME="$(echo "${TEMPLATE_DIR}" | cut -d/ -f3)"
134- export RELEASE_MSG="[Release Notes](https://github.com/${{ github.repository }}/releases/tag/${TEMPLATE_VERSION})"
135- export TEST_MODE=false
136- else
137- export TEMPLATE_NAME
138- TEMPLATE_NAME="$(echo "${TEMPLATE_DIR}" | cut -d/ -f3)-test"
139- export RELEASE_MSG="[Changes](https://github.com/${{ github.repository }}/commit/${TEMPLATE_VERSION})"
140- export TEST_MODE=true
141- fi
142- echo "Publishing template ${TEMPLATE_DIR} as ${TEMPLATE_NAME}..."
143- set -x
144- coder template push \
145- --directory "${TEMPLATE_DIR}" \
146- --var "workspace_image=${WORKSPACE_IMAGE}" \
147- --var test_mode=${TEST_MODE} \
148- --name "${TEMPLATE_VERSION}" \
149- --message "${RELEASE_MSG}" \
150- --yes \
151- "${TEMPLATE_NAME}"
152- set +x
153- echo
154- echo "Confirming template has been published..."
155- coder templates list --output json > /tmp/templates.json
156- export SELECTED_TEMPLATE
157- SELECTED_TEMPLATE=$(cat /tmp/templates.json | jq -r '.[] | select(.Template.name == "'"${TEMPLATE_NAME}"'")')
158- if [[ -z $SELECTED_TEMPLATE ]]; then
159- echo "Could not find any template published as $TEMPLATE_NAME."
160- exit 1
161- fi
162- echo "Template has been published successfully."
163-
164- - name : Tailscale Disconnect
165- if : success() || failure()
166- run : sudo -E tailscale logout
0 commit comments