From 61ad73a320641738e5e3314289efcaf7f0afe756 Mon Sep 17 00:00:00 2001 From: Ryan Fischbach Date: Tue, 13 Feb 2024 22:36:36 -0800 Subject: [PATCH 1/8] gha: handle manual tag case. [skip ci] --- .github/workflows/build-image.yml | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index ee51cfe..dddb87d 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -18,15 +18,18 @@ jobs: - name: "Determine Version" id: config_step run: |- - VER_BUILD=$(date +%H%M) - # limit to only first 3 chars - VER_BUILD=${VER_BUILD:0:3} - # 'strict' semver segments cannot start with 0 - VERSION_NUM="$(date +%y).$(date +%-m).$(date +%-d).${VER_BUILD#0}" - # recreate as INT, leaving 0's in place; creates a 'reasonable' 32-bit signed int. - VERSION_INT="$(date +%y)$(date +%m)$(date +%d)${VER_BUILD}" - - VERSION_STR=${VERSION_NUM} + if [[ ${{ github.ref_name }} =~ ^(v)([[:digit:]]+\..*)$ ]]; then + VERSION_STR=${BASH_REMATCH[2]} + else + VER_BUILD=$(date +%H%M) + # limit to only first 3 chars + VER_BUILD=${VER_BUILD:0:3} + # 'strict' semver segments cannot start with 0 + VERSION_NUM="$(date +%y).$(date +%-m).$(date +%-d).${VER_BUILD#0}" + # recreate as INT, leaving 0's in place; creates a 'reasonable' 32-bit signed int. + VERSION_INT="$(date +%y)$(date +%m)$(date +%d)${VER_BUILD}" + VERSION_STR=${VERSION_NUM} + fi echo "VERSION_STR=${VERSION_STR}" >> $GITHUB_OUTPUT echo "::notice::Version STR=${VERSION_STR}" #endjob build_cfg From 714b83e08c07a63bfa7b77821802c58872bde014 Mon Sep 17 00:00:00 2001 From: Ryan Fischbach Date: Tue, 13 Feb 2024 22:40:53 -0800 Subject: [PATCH 2/8] gha: dummy commit. --- .github/workflows/build-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index dddb87d..5690b11 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -1,4 +1,4 @@ -name: build image +name: "build image" on: push: From b8ff6564c43a931831b56dbbb2b3ab1f054c4114 Mon Sep 17 00:00:00 2001 From: Ryan Fischbach Date: Wed, 27 Mar 2024 14:21:32 -0700 Subject: [PATCH 3/8] gha: add alt_tags. --- .github/workflows/build-image.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 5690b11..2c4ea7c 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -12,8 +12,11 @@ jobs: build_cfg: runs-on: ubuntu-latest environment: default + env: + REF_NAME: ${{ github.ref_name }} outputs: VERSION_STR: ${{ steps.config_step.outputs.VERSION_STR }} + ALT_TAGS: ${{ steps.config_step.outputs.ALT_TAGS }} steps: - name: "Determine Version" id: config_step @@ -31,6 +34,15 @@ jobs: VERSION_STR=${VERSION_NUM} fi echo "VERSION_STR=${VERSION_STR}" >> $GITHUB_OUTPUT + + ALT_TAGS="" + if [[ "${{ github.ref_name }}" == "develop" ]]; then + ALT_TAGS+=",ci-develop" + else + ALT_TAGS=",ci-dev-${REF_NAME#**/}" + fi + echo "ALT_TAGS=${ALT_TAGS}" >> $GITHUB_OUTPUT + echo "::notice::Version STR=${VERSION_STR}" #endjob build_cfg @@ -60,7 +72,7 @@ jobs: "dockerfile": "Dockerfile", "arch_allowed": "amd64 arm64", "name": "${{ github.repository }}", - "tag": "${{ needs.build_cfg.outputs.VERSION_STR }}", + "tag": "${{ needs.build_cfg.outputs.VERSION_STR }}${{ needs.build_cfg.outputs.ALT_TAGS }}", "build_args": [ ] }, From c9489028302d5678de8d0e221d966c8a6258607f Mon Sep 17 00:00:00 2001 From: Jeremy Steele Date: Wed, 3 Apr 2024 13:00:14 -0400 Subject: [PATCH 4/8] use address field, temp disable arm64 --- .github/workflows/build-image.yml | 2 +- .github/workflows/tag-release.yml | 2 +- handlers/postmaster/postmaster.go | 10 ++-------- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 2c4ea7c..8712a98 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -70,7 +70,7 @@ jobs: }, "image": { "dockerfile": "Dockerfile", - "arch_allowed": "amd64 arm64", + "arch_allowed": "amd64", "name": "${{ github.repository }}", "tag": "${{ needs.build_cfg.outputs.VERSION_STR }}${{ needs.build_cfg.outputs.ALT_TAGS }}", "build_args": [ diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml index c19639d..ba39b82 100644 --- a/.github/workflows/tag-release.yml +++ b/.github/workflows/tag-release.yml @@ -65,7 +65,7 @@ jobs: }, "image": { "dockerfile": "Dockerfile", - "arch_allowed": "amd64 arm64", + "arch_allowed": "amd64", "name": "${{ github.repository }}", "tag": "${{ needs.build_cfg.outputs.VERSION_STR }}", "build_args": [ diff --git a/handlers/postmaster/postmaster.go b/handlers/postmaster/postmaster.go index 5a42c5c..4081d43 100644 --- a/handlers/postmaster/postmaster.go +++ b/handlers/postmaster/postmaster.go @@ -205,10 +205,7 @@ func (h *handler) SendMsg(ctx context.Context, msg courier.Msg) (courier.MsgStat return nil, fmt.Errorf("invalid chat mode") } - deviceId := msg.Channel().ConfigForKey("device_id", "").(string) - if deviceId == "" { - return nil, fmt.Errorf("invalid chat mode") - } + deviceId := msg.Channel().Address() status := h.Backend().NewMsgStatusForID(msg.Channel(), msg.ID(), courier.MsgErrored) @@ -282,10 +279,7 @@ func (h *handler) PurgeOutgoing(ctx context.Context, channel courier.Channel) er return fmt.Errorf("invalid chat mode") } - deviceID := channel.ConfigForKey("device_id", "").(string) - if deviceID == "" { - return fmt.Errorf("invalid chat mode") - } + deviceID := channel.Address() pr := purgeRequest{ DeviceID: deviceID, From 6c51ef929ba8f2c2f637f27958b9dc157e39da64 Mon Sep 17 00:00:00 2001 From: Jeremy Steele Date: Wed, 3 Apr 2024 13:46:39 -0400 Subject: [PATCH 5/8] Enable multiline on regex --- channel_log.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/channel_log.go b/channel_log.go index 8ab137d..bdfe616 100644 --- a/channel_log.go +++ b/channel_log.go @@ -45,7 +45,7 @@ func sanitizeSecrets(body string) string { pattern, exists := os.LookupEnv("COURIER_SANITIZE_PATTERN") if !exists { - pattern = "(?:^Po-Api-Key:.+\\n|^X-Api-Key:.+\\n|^Authorization:.+\\n|^Token:.+\\n)+" + pattern = `(?m)(?:^Po-Api-Key:.+\n|^X-Api-Key:.+\n|^Authorization:.+\n|^Token:.+\n)+` } if sanitizeSecretsRegexp == nil { From 7f9a185436d19763447a23ae8627fc9a50336852 Mon Sep 17 00:00:00 2001 From: Ryan Fischbach Date: Fri, 5 Apr 2024 11:10:47 -0700 Subject: [PATCH 6/8] gha: normalize tag creation. --- .github/workflows/build-image.yml | 43 +++++++++++++++++-------------- .github/workflows/tag-release.yml | 10 ++++--- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 8712a98..36f04a7 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -12,8 +12,6 @@ jobs: build_cfg: runs-on: ubuntu-latest environment: default - env: - REF_NAME: ${{ github.ref_name }} outputs: VERSION_STR: ${{ steps.config_step.outputs.VERSION_STR }} ALT_TAGS: ${{ steps.config_step.outputs.ALT_TAGS }} @@ -21,29 +19,34 @@ jobs: - name: "Determine Version" id: config_step run: |- - if [[ ${{ github.ref_name }} =~ ^(v)([[:digit:]]+\..*)$ ]]; then - VERSION_STR=${BASH_REMATCH[2]} - else - VER_BUILD=$(date +%H%M) - # limit to only first 3 chars - VER_BUILD=${VER_BUILD:0:3} - # 'strict' semver segments cannot start with 0 - VERSION_NUM="$(date +%y).$(date +%-m).$(date +%-d).${VER_BUILD#0}" - # recreate as INT, leaving 0's in place; creates a 'reasonable' 32-bit signed int. - VERSION_INT="$(date +%y)$(date +%m)$(date +%d)${VER_BUILD}" - VERSION_STR=${VERSION_NUM} - fi - echo "VERSION_STR=${VERSION_STR}" >> $GITHUB_OUTPUT + #VER_KIND = 'alpha' (not deployed) | 'dev' | 'beta' | 'gold' + VER_KIND=alpha + + VER_BUILD=$(date +%H%M) + # limit to only first 3 chars + VER_BUILD=${VER_BUILD:0:3} + # 'strict' semver segments cannot start with 0 + VERSION_NUM="$(date +%y).$(date +%-m).$(date +%-d).${VER_BUILD#0}" + # recreate as INT, leaving 0's in place; creates a 'reasonable' 32-bit signed int. + VERSION_INT="$(date +%y)$(date +%m)$(date +%d)${VER_BUILD}" + VERSION_STR=${VERSION_NUM} - ALT_TAGS="" - if [[ "${{ github.ref_name }}" == "develop" ]]; then - ALT_TAGS+=",ci-develop" + REF_NAME="${{ github.ref_name }}" + if [[ ${REF_NAME} =~ ^(v)([[:digit:]]+\..*)$ ]]; then + VER_KIND=gold + VERSION_STR=${BASH_REMATCH[2]} else - ALT_TAGS=",ci-dev-${REF_NAME#**/}" + ALT_TAGS="" + if [[ "${REF_NAME}" == "develop" ]]; then + ALT_TAGS+=",ci-develop" + else + ALT_TAGS=",ci-dev-${REF_NAME#**/}" + fi fi + echo "VERSION_STR=${VERSION_STR}" >> $GITHUB_OUTPUT echo "ALT_TAGS=${ALT_TAGS}" >> $GITHUB_OUTPUT - echo "::notice::Version STR=${VERSION_STR}" + echo "::notice::Version KIND=${VER_KIND}, STR=${VERSION_STR}${ALT_TAGS}, INT=${VERSION_INT}" #endjob build_cfg trigger-build: diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml index ba39b82..51035b7 100644 --- a/.github/workflows/tag-release.yml +++ b/.github/workflows/tag-release.yml @@ -11,6 +11,8 @@ jobs: runs-on: ubuntu-latest outputs: VERSION_STR: ${{ steps.config_step.outputs.VERSION_STR }} + VERSION_INT: ${{ steps.config_step.outputs.VERSION_INT }} + ALT_TAGS: ${{ steps.config_step.outputs.ALT_TAGS }} permissions: contents: write steps: @@ -22,13 +24,15 @@ jobs: VER_BUILD=${VER_BUILD:0:3} # 'strict' semver segments cannot start with 0 VERSION_NUM="$(date +%y).$(date +%-m).$(date +%-d).${VER_BUILD#0}" - # recreate as INT, leaving 0's in place; creates a 'reasonable' 32-bit signed int. VERSION_INT="$(date +%y)$(date +%m)$(date +%d)${VER_BUILD}" + echo "VERSION_INT=${VERSION_INT}" >> $GITHUB_OUTPUT VERSION_STR=${VERSION_NUM} + ALT_TAGS=",ci-main" echo "VERSION_STR=${VERSION_STR}" >> $GITHUB_OUTPUT - echo "::notice::Version STR=${VERSION_STR}" + echo "ALT_TAGS=${ALT_TAGS}" >> $GITHUB_OUTPUT + echo "::notice::Version STR=${VERSION_STR}${ALT_TAGS}" - name: "Create Release" uses: softprops/action-gh-release@v1 @@ -67,7 +71,7 @@ jobs: "dockerfile": "Dockerfile", "arch_allowed": "amd64", "name": "${{ github.repository }}", - "tag": "${{ needs.build_cfg.outputs.VERSION_STR }}", + "tag": "${{ needs.build_cfg.outputs.VERSION_STR }}${{ needs.build_cfg.outputs.ALT_TAGS }}", "build_args": [ ] }, From eafd846f3dd09245a211a835a1d7b739b8bd3a2a Mon Sep 17 00:00:00 2001 From: Ryan Fischbach Date: Wed, 24 Apr 2024 13:58:38 -0700 Subject: [PATCH 7/8] gha: deploy if version kind is dev. --- .github/workflows/build-image.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 36f04a7..bbc2b62 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -13,6 +13,7 @@ jobs: runs-on: ubuntu-latest environment: default outputs: + VERSION_KIND: ${{ steps.config_step.outputs.VERSION_KIND }} VERSION_STR: ${{ steps.config_step.outputs.VERSION_STR }} ALT_TAGS: ${{ steps.config_step.outputs.ALT_TAGS }} steps: @@ -20,7 +21,7 @@ jobs: id: config_step run: |- #VER_KIND = 'alpha' (not deployed) | 'dev' | 'beta' | 'gold' - VER_KIND=alpha + VER_KIND=dev VER_BUILD=$(date +%H%M) # limit to only first 3 chars @@ -45,6 +46,7 @@ jobs: fi echo "VERSION_STR=${VERSION_STR}" >> $GITHUB_OUTPUT echo "ALT_TAGS=${ALT_TAGS}" >> $GITHUB_OUTPUT + echo "VERSION_KIND=${VER_KIND}" >> $GITHUB_OUTPUT echo "::notice::Version KIND=${VER_KIND}, STR=${VERSION_STR}${ALT_TAGS}, INT=${VERSION_INT}" #endjob build_cfg @@ -80,7 +82,7 @@ jobs: ] }, "deployment": { - "deploy_flag": "${{ github.ref_type == 'branch' }}", + "deploy_flag": "${{ needs.build_cfg.outputs.VERSION_KIND == 'dev' }}", "k8s_project": "${{ env.K8S_PROJECT }}", "k8s_container": "${{ env.K8S_CONTAINER }}", "deploy_msg": "${{ env.SLACK_DEPLOY_MSG }}" From 877953725ea9f6fed42605c15f4cfefc7327efb2 Mon Sep 17 00:00:00 2001 From: Ryan Fischbach Date: Wed, 24 Apr 2024 14:00:24 -0700 Subject: [PATCH 8/8] gha: restore arm building. --- .github/workflows/build-image.yml | 2 +- .github/workflows/tag-release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index bbc2b62..6cab931 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -75,7 +75,7 @@ jobs: }, "image": { "dockerfile": "Dockerfile", - "arch_allowed": "amd64", + "arch_allowed": "amd64 arm64", "name": "${{ github.repository }}", "tag": "${{ needs.build_cfg.outputs.VERSION_STR }}${{ needs.build_cfg.outputs.ALT_TAGS }}", "build_args": [ diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml index 51035b7..48212ab 100644 --- a/.github/workflows/tag-release.yml +++ b/.github/workflows/tag-release.yml @@ -69,7 +69,7 @@ jobs: }, "image": { "dockerfile": "Dockerfile", - "arch_allowed": "amd64", + "arch_allowed": "amd64 arm64", "name": "${{ github.repository }}", "tag": "${{ needs.build_cfg.outputs.VERSION_STR }}${{ needs.build_cfg.outputs.ALT_TAGS }}", "build_args": [