From 0d31a51eeb4a6b7dd599e14786abcc4d418e3987 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Fri, 14 Feb 2020 21:32:07 -0500 Subject: [PATCH] Add github release creation --- .github/workflows/{ci.yml => code.yml} | 55 ++---------- .github/workflows/release.yml | 113 +++++++++++++++++++++++++ .gitignore | 1 + ci/release-image/.gitignore | 1 + ci/{ => release-image}/Dockerfile | 7 +- 5 files changed, 123 insertions(+), 54 deletions(-) rename .github/workflows/{ci.yml => code.yml} (53%) create mode 100644 .github/workflows/release.yml create mode 100644 ci/release-image/.gitignore rename ci/{ => release-image}/Dockerfile (84%) diff --git a/.github/workflows/ci.yml b/.github/workflows/code.yml similarity index 53% rename from .github/workflows/ci.yml rename to .github/workflows/code.yml index e2e92628..a04ee7f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/code.yml @@ -1,5 +1,8 @@ -name: ci -on: [push, pull_request, release] +name: code +on: [push, pull_request] + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: fmt: @@ -21,8 +24,6 @@ jobs: uses: ./ci/image with: args: yarn && yarn vscode && yarn fmt - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} lint: runs-on: ubuntu-latest @@ -43,8 +44,6 @@ jobs: uses: ./ci/image with: args: yarn && yarn vscode && yarn lint - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} test: runs-on: ubuntu-latest @@ -65,47 +64,3 @@ jobs: uses: ./ci/image with: args: yarn && yarn vscode && yarn test - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - release-linux-amd64: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v1 - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - - - name: Run release.sh - uses: ./ci/image - with: - args: yarn && yarn vscode && ./ci/release.sh - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - release-macos: - runs-on: macos-latest - steps: - - uses: actions/checkout@v1 - - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v1 - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - - - name: Run release.sh - run: yarn && yarn vscode && ./ci/release.sh - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..5838dc40 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,113 @@ +name: release +on: + push: +# tags: +# - 'v*' + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + linux-amd64: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + - uses: actions/cache@v1 + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Run release.sh + uses: ./ci/image + with: + args: yarn && yarn vscode && ./ci/release.sh + env: + PACKAGE: true + - name: Get release name + id: get-release-name + run: echo "::set-output name=name::$(cd release && ls *.tar.gz)" + + - name: Upload release as artifact + uses: actions/upload-artifact@master + with: + name: ${{ steps.get-release-name.outputs.name }} + path: release/${{ steps.get-release-name.outputs.name }} + + - name: Create Release + id: create-release + uses: actions/create-release@v1 + with: + tag_name: v2.1.0 + release_name: Release v2.1.0 + draft: true + - name: Upload release + id: upload-release-asset + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ steps.create-release.outputs.upload_url }} + asset_name: ${{ steps.get-release-name.outputs.name }} + asset_path: release/${{ steps.get-release-name.outputs.name }} + asset_content_type: application/gzip + + - name: Copy release into release image build context + uses: ./ci/image + with: + args: cp release/${{ steps.get-release-name.outputs.name }} ci/release-image + - name: Publish codercom/code-server docker container + uses: elgohr/Publish-Docker-Github-Action@master + with: + name: codercom/code-server + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + context: ci/release-image + tags: "anmol" + + macos: + runs-on: macos-latest + steps: + - uses: actions/checkout@v1 + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + - uses: actions/cache@v1 + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Run release.sh + run: yarn && yarn vscode && ./ci/release.sh + env: + PACKAGE: true + - name: Get release name + id: get-release-name + run: echo "::set-output name=name::$(cd release && ls *.zip)" + + - name: Upload release as artifact + uses: actions/upload-artifact@master + with: + name: ${{ steps.get-release-name.outputs.name }} + path: release/${{ steps.get-release-name.outputs.name }} + + - name: Create Release + id: create-release + uses: actions/create-release@v1 + with: + tag_name: v2.1.0 + release_name: Release v2.1.0 + draft: true + - name: Upload release + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ steps.create-release.outputs.upload_url }} + asset_name: ${{ steps.get-release-name.outputs.name }} + asset_path: release/${{ steps.get-release-name.outputs.name }} + asset_content_type: application/zip diff --git a/.gitignore b/.gitignore index d228a31f..fc190e5f 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ dist* out* release node_modules +binaries diff --git a/ci/release-image/.gitignore b/ci/release-image/.gitignore new file mode 100644 index 00000000..c9cabf53 --- /dev/null +++ b/ci/release-image/.gitignore @@ -0,0 +1 @@ +code-server*.tar.gz diff --git a/ci/Dockerfile b/ci/release-image/Dockerfile similarity index 84% rename from ci/Dockerfile rename to ci/release-image/Dockerfile index c7064ced..751230e0 100644 --- a/ci/Dockerfile +++ b/ci/release-image/Dockerfile @@ -3,11 +3,10 @@ FROM debian:10 RUN apt-get update RUN apt-get install -y curl -ARG DOWNLOAD_URL=https://github.com/cdr/code-server/releases/download/2.1698/code-server2.1698-vsc1.41.1-linux-x86_64.tar.gz - -RUN cd /tmp && curl -L "$DOWNLOAD_URL" | \ - tar -xz && \ +COPY code-server*.tar.gz /tmp +RUN cd /tmp && tar -xzf code-server*.tar.gz && \ cp code-server*/code-server /usr/local/bin/code-server +RUN rm -rf /tmp/* # https://wiki.debian.org/Locale#Manually RUN apt-get install -y locales