From e0369573c87569e58028a83ad073ac1a5fb3f0fb Mon Sep 17 00:00:00 2001 From: Chi Wang Date: Mon, 27 Sep 2021 12:32:24 +0800 Subject: [PATCH] Add actions to automatically relase bazelci_rules (#1225) --- .github/workflows/release-rules.yml | 53 +++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/release-rules.yml diff --git a/.github/workflows/release-rules.yml b/.github/workflows/release-rules.yml new file mode 100644 index 0000000000..de32b5a1d7 --- /dev/null +++ b/.github/workflows/release-rules.yml @@ -0,0 +1,53 @@ +name: release-rules +on: + push: + tags: + - "rules-[0-9]+.[0-9]+.[0-9]+" +jobs: + create-release: + name: create-release + runs-on: ubuntu-latest + outputs: + upload_url: ${{ steps.release.outputs.upload_url }} + rules_version: ${{ env.RULES_VERSION }} + steps: + - name: Get the release version from the tag + shell: bash + if: env.RULES_VERSION == '' + run: | + echo "RULES_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + echo "version is: ${{ env.RULES_VERSION }}" + - name: Create GitHub release + id: release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.RULES_VERSION }} + release_name: ${{ env.RULES_VERSION }} + + build-release: + name: build-release + needs: ['create-release'] + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 1 + - name: Build release asset + shell: bash + run: | + staging="bazelci_${{ needs.create-release.outputs.rules_version }}" + cp -r rules "$staging" + tar czf "$staging.tar.gz" "$staging" + echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV + - name: Upload release asset + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create-release.outputs.upload_url }} + asset_path: ${{ env.ASSET }} + asset_name: ${{ env.ASSET }} + asset_content_type: application/octet-stream \ No newline at end of file