Skip to content

Commit a460e27

Browse files
authored
Add workflow for continuous delivery (#569)
1 parent 02fdf8d commit a460e27

File tree

3 files changed

+65
-8
lines changed

3 files changed

+65
-8
lines changed

.github/workflows/CI.yml

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,38 @@ jobs:
167167
path: ${{ env.FPM_RELEASE }}
168168

169169
upload-artifacts:
170-
if: github.event_name == 'release'
170+
if: ${{ github.event_name == 'release' && contains(github.ref, 'v') || github.event_name == 'push' }}
171171
runs-on: ubuntu-latest
172172
needs:
173173
- build
174174

175175
steps:
176+
- id: deploy-on-push
177+
if: ${{ github.event_name == 'push' }}
178+
run:
179+
echo "::set-output name=result::${{ env.DEPLOY_BRANCH }}"
180+
env:
181+
DEPLOY_BRANCH: ${{ secrets.DEPLOY_BRANCH && contains(github.ref, secrets.DEPLOY_BRANCH) && 1 || 0 }}
182+
183+
- uses: actions/checkout@v2
184+
if: ${{ github.event_name == 'push' }}
185+
176186
- name: Download Artifacts
177187
uses: actions/download-artifact@v2
178188
with:
179189
path: ${{ github.workspace }} # This will download all files
180190

191+
- name: Normalize file names for continuous delivery
192+
if: ${{ github.event_name == 'push' }}
193+
run: |
194+
for output in fpm-*/fpm-*; do
195+
pushd $(dirname "$output")
196+
mv -v $(basename $output) $(basename $output | sed -E '${{ env.replace }}')
197+
popd
198+
done
199+
env:
200+
replace: 's/-([0-9]+\.[0-9]+\.[0-9]+-[0-9]+-g)?[0-9a-f]+//'
201+
181202
- name: Create SHA256 checksums
182203
run: |
183204
for output in fpm-*/fpm-*; do
@@ -186,12 +207,18 @@ jobs:
186207
popd
187208
done
188209
210+
- name: Move/Create continuous tag
211+
if: ${{ github.event_name == 'push' && steps.deploy-on-push.outputs.result != 0 }}
212+
run: |
213+
git tag --force 'current' ${{ github.sha }}
214+
git push --tags --force
215+
189216
- name: Upload assets
190-
if: github.event_name == 'release'
191217
uses: svenstaro/upload-release-action@v2
218+
if: ${{ github.event_name == 'release' || steps.deploy-on-push.outputs.result != 0 }}
192219
with:
193220
repo_token: ${{ secrets.GITHUB_TOKEN }}
194221
file: fpm-*/fpm-*
195222
file_glob: true
196-
tag: ${{ github.ref }}
223+
tag: ${{ github.event_name == 'release' && github.ref || 'current'}}
197224
overwrite: true

.github/workflows/release.yml

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,39 @@ jobs:
9898
path: ${{ env.OUTPUT }}
9999

100100
upload-artifacts:
101-
if: github.event_name == 'release'
101+
if: ${{ github.event_name == 'release' && contains(github.ref, 'v') || github.event_name == 'push' }}
102102
runs-on: ubuntu-latest
103103
needs:
104104
- source-archive
105105
- source-single-file
106106

107107
steps:
108+
- id: deploy-on-push
109+
if: ${{ github.event_name == 'push' }}
110+
run:
111+
echo "::set-output name=result::${{ env.DEPLOY_BRANCH }}"
112+
env:
113+
DEPLOY_BRANCH: ${{ secrets.DEPLOY_BRANCH && contains(github.ref, secrets.DEPLOY_BRANCH) && 1 || 0 }}
114+
115+
- uses: actions/checkout@v2
116+
if: ${{ github.event_name == 'push' }}
117+
108118
- name: Download Artifacts
109119
uses: actions/download-artifact@v2
110120
with:
111121
path: ${{ github.workspace }} # This will download all files
112122

123+
- name: Normalize file names for continuous delivery
124+
if: ${{ github.event_name == 'push' }}
125+
run: |
126+
for output in fpm-*/fpm-*; do
127+
pushd $(dirname "$output")
128+
mv -v $(basename $output) $(basename $output | sed -E '${{ env.replace }}')
129+
popd
130+
done
131+
env:
132+
replace: 's/-([0-9]+\.[0-9]+\.[0-9]+-[0-9]+-g)?[0-9a-f]+//'
133+
113134
- name: Create SHA256 checksums
114135
run: |
115136
for output in fpm-*/fpm-*; do
@@ -118,12 +139,18 @@ jobs:
118139
popd
119140
done
120141
142+
- name: Move/Create continuous tag
143+
if: ${{ github.event_name == 'push' && steps.deploy-on-push.outputs.result != 0 }}
144+
run: |
145+
git tag --force 'current' ${{ github.sha }}
146+
git push --tags --force
147+
121148
- name: Upload assets
122-
if: ${{ github.event_name == 'release' }}
149+
if: ${{ github.event_name == 'release' || steps.deploy-on-push.outputs.result != 0 }}
123150
uses: svenstaro/upload-release-action@v2
124151
with:
125152
repo_token: ${{ secrets.GITHUB_TOKEN }}
126153
file: fpm-*/fpm-*
127154
file_glob: true
128-
tag: ${{ github.ref }}
155+
tag: ${{ github.event_name == 'release' && github.ref || 'current'}}
129156
overwrite: true

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@ non-Fortran related package manager.
3232
### Setting up fpm
3333

3434
#### Binary download
35-
`x86-64` binaries are available [to download](https://github.com/fortran-lang/fpm/releases) for Windows, MacOS and Linux.
35+
36+
Binaries for the latest stable release are available [to download](https://github.com/fortran-lang/fpm/releases/latest) for Windows, MacOS, and Linux.
3637

3738
__Note:__ On Linux and MacOS, you will need to enable executable permission before you can use the binary.
3839

3940
_e.g._ `$ chmod u+x fpm-0.4.0-linux-x86_64`
4041

42+
The binaries at the [current tag](https://github.com/fortran-lang/fpm/releases/tag/current) are updated automatically to always provide the current git version from the default branch.
43+
4144

4245
#### [Conda]
4346

@@ -147,7 +150,7 @@ To build manually using the single source distribution, run the following code (
147150

148151
```
149152
mkdir _tmp
150-
curl -LJ https://github.com/fortran-lang/fpm/releases/download/v0.4.0/fpm-0.4.0.F90 > _tmp/fpm.F90
153+
curl -LJ https://github.com/fortran-lang/fpm/releases/download/current/fpm.F90 > _tmp/fpm.F90
151154
gfortran -J _tmp _tmp/fpm.F90 -o _tmp/fpm
152155
_tmp/fpm install --flag "-g -fbacktrace -O3"
153156
rm -r _tmp

0 commit comments

Comments
 (0)