This repository was archived by the owner on Oct 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 99
140 lines (134 loc) · 4.73 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
---
name: Release
on:
workflow_dispatch:
inputs:
version-type:
description: How major the changes are [ major | minor | patch | prerelease ]
required: true
default: patch
jobs:
bump-commit:
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.new-commit.outputs.version }}
commit-id: ${{ steps.new-commit.outputs.commit-id }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
registry-url: https://registry.npmjs.org/
cache: yarn
- name: Configure git credentials
uses: OleksiyRudenko/gha-git-credentials@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ github.actor }}
email: ${{ github.actor }}@users.noreply.github.com
- run: yarn config set version-git-message "Release v%s"
- run: yarn version --${{ github.event.inputs.version-type }} --preid beta
- id: new-commit
run: |
echo "::set-output name=version::v$(node -pe "require('./package.json').version")"
echo "::set-output name=commit-id::$(git log -1 --pretty=format:%H)"
- name: push commit
run: git push --follow-tags
create-gh-release:
runs-on: ubuntu-22.04
needs: bump-commit
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
release_id: ${{ steps.create_release.outputs.id }}
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
target_commitish: ${{ needs.bump-commit.outputs.commit-id }}
tag_name: ${{ needs.bump-commit.outputs.version }}
release_name: Release ${{ needs.bump-commit.outputs.version }}
draft: true
prerelease: ${{ contains(github.event.inputs.version-type, 'pre') }}
release-binaries:
runs-on: ubuntu-22.04
needs: create-gh-release
strategy:
fail-fast: true
matrix:
os: [alpine, linux, macos, win]
arch: [x64, arm64]
node-version: [16]
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- run: |
git pull --no-commit
git reset --hard origin/master
git checkout ${{ needs.bump-commit.outputs.commit-id }}
- uses: actions/setup-node@v3
with:
registry-url: https://registry.npmjs.org/
cache: yarn
- run: yarn
- name: Build ${{ matrix.os }} ${{ matrix.arch }} binary
run: |
npx -y pkg \
-t node${{ matrix.node-version }}-${{ matrix.os }}-${{ matrix.arch }} \
-o 2bored2wait-${{ matrix.os }}-${{ matrix.arch }} \
--compress gzip \
./check.js
- id: find-file-name
run: |
echo "::set-output name=file-name::$(ls 2bored2wait-${{ matrix.os }}-${{ matrix.arch }}*)"
- name: Upload ${{ matrix.os }}-${{ matrix.arch }} binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-gh-release.outputs.upload_url }}
asset_name: ${{ steps.find-file-name.outputs.file-name }}
asset_path: ./${{ steps.find-file-name.outputs.file-name }}
asset_content_type: application/octet-stream
publish-release:
runs-on: ubuntu-22.04
needs: [release-binaries, create-gh-release]
steps:
- uses: eregon/publish-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ needs.create-gh-release.outputs.release_id }}
build-docker:
runs-on: ubuntu-22.04
needs: bump-commit
steps:
- uses: actions/checkout@v3
- run: |
git pull --no-commit
git reset --hard origin/master
git checkout ${{ needs.bump-commit.outputs.commit-id }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/arm/v7,linux/arm64/v8,linux/arm/v6,linux/amd64,linux/ppc64le,linux/s390x
push: true
tags: 2bored2wait/2bored2wait:latest
- name: Update repo description
uses: peter-evans/dockerhub-description@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: 2bored2wait/2bored2wait