Publish Release packages #18
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish Release packages | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| pkgRepo: | |
| description: "Source repository to pull packages from" | |
| type: string | |
| default: "packages.nginx.org" | |
| pkgVersion: | |
| description: 'Agent version' | |
| type: string | |
| default: "" | |
| uploadAzure: | |
| description: 'Publish packages Azure storage' | |
| type: boolean | |
| default: false | |
| uploadGithub: | |
| description: 'Publish packages to GitHub release' | |
| type: boolean | |
| default: false | |
| defaults: | |
| run: | |
| shell: bash | |
| permissions: | |
| contents: read | |
| jobs: | |
| vars: | |
| name: Set workflow variables | |
| runs-on: ubuntu-22.04 | |
| outputs: | |
| github_release: ${{steps.vars.outputs.github_release }} | |
| upload_azure: ${{steps.vars.outputs.upload_azure }} | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | |
| with: | |
| ref: ${{ inputs.releaseBranch }} | |
| - name: Set variables | |
| id: vars | |
| run: | | |
| echo "github_release=${{ inputs.uploadGithub }}" >> $GITHUB_OUTPUT | |
| echo "upload_azure=${{ inputs.uploadAzure }}" >> $GITHUB_OUTPUT | |
| cat $GITHUB_OUTPUT | |
| upload-release-assets: | |
| name: Upload assets | |
| runs-on: ubuntu-22.04 | |
| needs: [vars] | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | |
| with: | |
| ref: ${{ inputs.releaseBranch }} | |
| - name: Download Packages | |
| run: | |
| | | |
| echo "Checking Packages in ${{inputs.pkgRepo}}/nginx-agent" | |
| echo "${{secrets.PUBTEST_CERT}}" > pubtest.crt | |
| echo "${{secrets.PUBTEST_KEY}}" > pubtest.key | |
| PKG_REPO=${{inputs.pkgRepo}} CERT=pubtest.crt KEY=pubtest.key DL=1 scripts/packages/package-check.sh ${{inputs.pkgVersion}} | |
| for i in $(find ${{inputs.pkgRepo}}/nginx-agent | grep -e "nginx-agent[_-]${{inputs.pkgVersion}}"); do | |
| if [[ "$i" == *.deb ]]; then | |
| echo "Renaming ${i} to ${i/_/-/}" | |
| mv "${i}" "${i/_/-/}" | |
| fi | |
| if [[ "$i" == *.apk ]]; then | |
| ver=$(echo "$i" | grep -o -e "v[0-9]*\.[0-9]*") | |
| arch=$(echo "$i" | grep -o -F -e "x86_64" -e "aarch64") | |
| dest="$(dirname "$i")/nginx-agent-${{inputs.pkgVersion}}-$ver-$arch.apk" | |
| echo "Renaming ${i} to ${dest}" | |
| mv "${i}" "${dest}" | |
| fi | |
| done | |
| find ${{inputs.pkgRepo}}/nginx-agent | grep -e "nginx-agent[_-]${{inputs.pkgVersion}}" | |
| - name: GitHub Upload | |
| continue-on-error: true | |
| if: ${{ needs.vars.outputs.github_release == 'true' }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # clobber overwrites existing assets of the same name | |
| run: | | |
| gh release upload --clobber v${{ inputs.pkgVersion }} \ | |
| $(find ${{inputs.pkgRepo}}/nginx-agent | grep -e "nginx-agent[_-]${{inputs.pkgVersion}}") | |
| - name: Azure Login | |
| if: ${{ inputs.uploadAzure == true }} | |
| uses: azure/login@8c334a195cbb38e46038007b304988d888bf676a # v2.0.0 | |
| with: | |
| creds: ${{ secrets.AZURE_CREDENTIALS }} | |
| - name: Azure Upload | |
| if: ${{ inputs.uploadAzure == true }} | |
| uses: azure/CLI@965c8d7571d2231a54e321ddd07f7b10317f34d9 # v2.0.0 | |
| with: | |
| inlineScript: | | |
| for i in $(find ${{inputs.pkgRepo}}/nginx-agent | grep -e "nginx-agent[_-]${{inputs.pkgVersion}}"); do | |
| dest="nginx-agent/${GITHUB_REF##*/}/${i##*/}" | |
| echo "Uploading ${i} to ${dest}" | |
| az storage blob upload --auth-mode=login -f "$i" -c ${{ secrets.AZURE_CONTAINER_NAME }} \ | |
| --account-name ${{ secrets.AZURE_ACCOUNT_NAME }} --overwrite -n ${dest} | |
| done | |
| - name: Azure Logout | |
| if: ${{ inputs.uploadAzure == true }} | |
| run: | | |
| az logout || exit 0 |