Skip to content

Commit

Permalink
Merge to master publish win packages (#83)
Browse files Browse the repository at this point in the history
* Use simple playbook to upload windows packages
  • Loading branch information
luckslovez authored Jan 30, 2024
1 parent df3fc62 commit dc0477e
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 8 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/merge-to-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Publish linux packages to staging
uses: newrelic/[email protected]
env:
TAG: ${{ needs.get-release-tag.outputs.tag }}"
TAG: ${{ needs.get-release-tag.outputs.tag }}
GPG_MAIL: ${{ secrets.LOGGING_GPG_MAIL }}
GPG_PASSPHRASE: ${{ secrets.OHAI_GPG_PASSPHRASE }}
GPG_PRIVATE_KEY_BASE64: ${{ secrets.OHAI_GPG_PRIVATE_KEY_BASE64 }} # base64 encoded
Expand Down Expand Up @@ -62,3 +62,13 @@ jobs:
# used for signing package stuff
gpg_passphrase: ${{ env.GPG_PASSPHRASE }}
gpg_private_key_base64: ${{ env.GPG_PRIVATE_KEY_BASE64 }}
# TODO: fill with prod parameters when ready
#- name: Publish linux packages to production

publish-windows:
name: Publish windows packages to logging's production bucket
needs: get-release-tag
uses: ./.github/workflows/run_task.yml
with:
container_make_target: "ansible/upload-win-packages PR_TAG=${{ needs.get-release-tag.outputs.tag }}"
secrets: inherit
4 changes: 0 additions & 4 deletions ansible/Ansible.common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ ansible/dependencies: $(ROLES_PATH) $(COLLECTIONS_PATH)
ansible/prepare-inventory:
@sed "s/PR_NUMBER/${PR_NUMBER}/g" $(ANSIBLE_INVENTORY_TEMPLATE) > $(ANSIBLE_INVENTORY)

# Bundles the above
.PHONY: ansible/common
ansible/common: ansible/dependencies ansible/prepare-inventory

# Removes "collections" and "roles" folders
.PHONY: ansible/clean
ansible/clean:
Expand Down
2 changes: 1 addition & 1 deletion ansible/build-fb-suse/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include ../Ansible.common.mk
.DEFAULT_GOAL := build-fb-suse

.PHONY: build-fb-suse
build-fb-suse: ansible/common
build-fb-suse: ansible/dependencies ansible/prepare-inventory
ansible-playbook $(ANSIBLE_FOLDER)/playbook.yml -i $(ANSIBLE_INVENTORY)
@sed "s/PR_NUMBER/${PR_NUMBER}/g" playbook-localhost.yml.dist > playbook-localhost.yml
ansible-playbook $(ANSIBLE_FOLDER)/playbook-localhost.yml
Expand Down
2 changes: 1 addition & 1 deletion ansible/provision-and-execute-tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include ../Ansible.common.mk
.DEFAULT_GOAL := provision-and-execute-tests

.PHONY: provision-and-execute-tests
provision-and-execute-tests: ansible/common
provision-and-execute-tests: ansible/dependencies ansible/prepare-inventory
ansible-playbook $(ANSIBLE_FOLDER)/playbook.yml -i $(ANSIBLE_INVENTORY)

.PHONY: clean
Expand Down
14 changes: 14 additions & 0 deletions ansible/upload-win-packages/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
include ../Ansible.common.mk

.DEFAULT_GOAL := upload-win-packages

.PHONY: generateMatrix
generateMatrix:
$(MAKE) -C ../../versions generateMatrices

.PHONY: upload-win-packages
upload-win-packages: ansible/dependencies generateMatrix
ansible-playbook $(ANSIBLE_FOLDER)/playbook.yml -i $(ANSIBLE_INVENTORY)

.PHONY: clean
clean: ansible/clean
26 changes: 26 additions & 0 deletions ansible/upload-win-packages/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
- name: Upload windows packages
hosts: localhost
vars:
pr_tag: "{{ lookup('ansible.builtin.env', 'PR_TAG') }}"
windows_bucket: logging-fb-windows-packages
windows_matrix: "{{ lookup('file','../../versions/windowsMatrix.json') | from_json }}"
roles:
- andrewrothstein.gh
tasks:
- name: Set windows artifact names
set_fact:
windows_artifacts: "{{ windows_matrix | community.general.json_query('[*].targetPackageName') }}"

- name: Download windows artifacts from github pre_release
ansible.builtin.command: "gh release download {{ pr_tag }} --pattern '{{ item }}' --skip-existing"
loop: "{{ windows_artifacts }}"

- name: Upload windows artifacts
amazon.aws.s3_object:
bucket: "{{ windows_bucket }}"
object: "{{ item }}"
src: "{{ item }}"
mode: put
permission: public-read
purge_tags: false
loop: "{{ windows_artifacts }}"
5 changes: 5 additions & 0 deletions ansible/upload-win-packages/requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
collections:
- name: community.aws
- name: community.general
roles:
- name: andrewrothstein.gh
3 changes: 2 additions & 1 deletion versions/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ generateMatrices:
pip3 install -r requirements.txt
python3 strategyMatrix.py > strategyMatrix.json
cat strategyMatrix.json | jq 'map(select(.osDistro == "sles"))' -c > slesMatrix.json
cat strategyMatrix.json | jq 'map(select(.osDistro != "sles"))' -c > linuxAndWindowsMatrix.json
cat strategyMatrix.json | jq 'map(select(.osDistro != "sles"))' -c > linuxAndWindowsMatrix.json
cat strategyMatrix.json | jq 'map(select(.osDistro == "windows-server"))' -c > windowsMatrix.json

0 comments on commit dc0477e

Please sign in to comment.