cd #151
This file contains 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: cd | |
on: | |
push: | |
tags: | |
- "v[0-9]+.[0-9]+.[0-9]+" | |
workflow_run: | |
workflows: | |
- ci | |
types: | |
- completed | |
branches: | |
- master | |
env: | |
TERM: xterm | |
GO_VERSION: 1.19.6 | |
MM_RUDDER_PLUGINS_PROD: ${{ secrets.MM_RUDDER_PLUGINS_PROD }} | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: ci/checkout-repo | |
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 | |
with: | |
fetch-depth: 0 # We need these for proper release notes | |
- name: ci/setup-go | |
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0 | |
with: | |
go-version: "${{ env.GO_VERSION }}" | |
cache: true | |
- name: ci/build | |
run: make dist | |
- name: ci/generate-release-notes | |
run: | | |
printf "Supported Mattermost Server Versions: **$(cat plugin.json | jq .min_server_version -r)+** \n## Enhancements\n\n## Fixes\n" >> dist/release-notes.md | |
if [[ $(git tag -l | wc -l) -eq 1 ]]; then | |
git log --pretty='format:- %h %s' --abbrev-commit --no-decorate --no-color $(git rev-list --max-parents=0 HEAD) HEAD >> dist/release-notes.md | |
else | |
git log --pretty='format:- %h %s' --abbrev-commit --no-decorate --no-color $(git describe --tags --abbrev=0 $(git describe --tags --abbrev=0)^)..HEAD >> dist/release-notes.md | |
fi | |
- name: ci/upload-artifacts | |
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 | |
with: | |
name: dist | |
path: | | |
dist/*.tar.gz | |
dist/release-notes.md | |
retention-days: 5 ## No need to keep CI builds more than 5 days | |
deploy-ci: | |
runs-on: ubuntu-22.04 | |
if: ${{ github.ref_name == 'master' }} | |
needs: | |
- build | |
steps: | |
- name: cd/checkout-repository | |
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 | |
- name: cd/download-artifacts | |
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 | |
with: | |
name: dist | |
path: dist | |
- name: cd/rename-artifacts | |
run: mv dist/*.tar.gz dist/${GITHUB_REPOSITORY#*/}-ci.tar.gz | |
- name: cd/setup-aws | |
uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 # v1.7.0 | |
with: | |
aws-region: us-east-1 | |
aws-access-key-id: ${{ secrets.PLUGIN_AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.PLUGIN_AWS_SECRET_ACCESS_KEY }} | |
- name: cd/artifact-upload | |
run: | | |
aws s3 cp dist/${GITHUB_REPOSITORY#*/}-ci.tar.gz s3://mattermost-plugins-ci/ci/ --acl public-read --cache-control no-cache | |
release-s3: | |
runs-on: ubuntu-22.04 | |
if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
needs: | |
- build | |
steps: | |
- name: cd/checkout-repository | |
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 | |
- name: cd/download-artifacts | |
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 | |
with: | |
name: dist | |
path: dist | |
- name: cd/rename-artifacts | |
run: | | |
mv dist/*.tar.gz dist/${GITHUB_REPOSITORY#*/}-latest.tar.gz | |
cp dist/${GITHUB_REPOSITORY#*/}-latest.tar.gz dist/${GITHUB_REPOSITORY#*/}-${GITHUB_REF_NAME}.tar.gz | |
- name: cd/setup-aws | |
uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 # v1.7.0 | |
with: | |
aws-region: us-east-1 | |
aws-access-key-id: ${{ secrets.PLUGIN_AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.PLUGIN_AWS_SECRET_ACCESS_KEY }} | |
- name: cd/artifact-upload | |
run: | | |
aws s3 cp dist/${GITHUB_REPOSITORY#*/}-${GITHUB_REF_NAME}.tar.gz s3://mattermost-plugins-ci/release/ --acl public-read --cache-control no-cache | |
release-github: | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-22.04 | |
needs: | |
- release-s3 | |
steps: | |
- name: cd/checkout-repository | |
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 | |
- name: cd/download-artifact | |
uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # v3.0.1 | |
with: | |
name: dist | |
path: dist | |
- name: cd/create-github-release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
run: | | |
gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --notes-file dist/release-notes.md dist/*.tar.gz |